Pushing a git tag to Github in a plugin

Hey, thanks for Drone & thanks for your answers in Discourse! From searching these forums I’ve found that the following works for pushing a git tag:

pipeline:
  push-tag:
    image: docker:git
    commands:
    - git tag whatever
    - git push origin --tags

where the commands are done explicitly in the Drone pipeline. However, when attempting to do the same thing from inside a plugin, I get an error (presumably auth related)

pipeline:
  push-tag-plugin:
    image: gempesaw/drone-git-tag
    plugin: true

which gives an error like

fatal: could not read Username for 'https://github.com': No such device or address

Is this expected behavior? Is there a way for plugins to push to github ?

The gempesaw/drone-git-tag image just runs the same commands as in the explicit version. Other info … we’re running drone 0.8.1 in kubernetes. The repo settings in Drone are ‘Trusted’ and ‘Private’. The repo in Github is also private.

Thanks again, Brad! Introducing fast & useful CI/CD to my company has been one of my long term personal goals, and Drone has been a huge part of that effort for us. :slight_smile:

related topics:

Is this expected behavior? Is there a way for plugins to push to github ?

yes, drone does some magic under the covers where it automatically creates a .netrc file with your git credentials for command steps. If you are creating a plugin, you need to handle creation of this file. Here are bash and Go examples that demonstrate:

also there is an existing plugin you might be able to use: https://github.com/appleboy/drone-git-push/blob/master/DOCS.md

1 Like

oh, great, that’s quite straightforward. Thanks!

---
kind: pipeline
type: docker
name: default

steps:
- name: some-step-creating-commits-and-tags
/-/

- name: push-tag
  image: docker:git
  commands:
  - git push origin --tags
  when:
    branch:
    - master

doesn’t work, as the original poster states. Has it changed over the years or am I doing something wrong? The pipeline step logs were:

1git: Pulling from library/docker
1s
2Digest: sha256:fe99b62ceb53a90c054c55e86440cf00d13b3ff2f3d99692a0bef4adc1b45c67
9s
3Status: Downloaded newer image for docker:git
9s
4+ git push origin --tags
9s
5fatal: could not read Username for 'https://github.com': terminal prompts disabled

To be explicit, I want this build step to push whatever commits&tags the pipeline has created back to the remote the project was cloned from, and to the current branch the step is working against – master in my example.