1

I am trying to write my first custom plugin for drone ci that will change git tag and push back to repository. The plugin will be written in GO. My question is, how to feed https://docs.drone.io/pipeline/environment/reference/ inside the GO application.

Do you I have to pass it like this:

kind: pipeline
type: docker
name: default

steps:
- name: custom/plugin
  image: custom/tag
  settings:
    url: $DRONE_GIT_HTTP_URL`

and access in the GO application as follows:

func main() {

   url := os.GetEnv("URL")
softshipper
  • 32,463
  • 51
  • 192
  • 400

1 Answers1

2

The standard Drone environment variables are always injected into all steps within all pipelines, so generally it would be better if you check for the regular names of the environment variables.

Specific to your use case, you should change the code to url := os.GetEnv("PLUGIN_URL") as Drone automatically prefixes all settings with the PLUGIN_ prefix.

  • Thanks for your answer. But to get the variables inside the container, I have to import it via for example settings right? – softshipper Apr 21 '20 at 09:47
  • 1
    nope, Drone automatically injects repository, build and commit details into all pipeline containers (including plugin containers) by default as environment variables. See the full list of environment variables that are available here: https://docs.drone.io/pipeline/environment/reference/ – Brad Rydzewski Apr 21 '20 at 12:28