Maximilian Mordig
Maximilian Mordig

Reputation: 1399

Share variables between steps in drone.io

It seems to me that drone.io does not share parameters across pipeline steps. Is it possible to read the parameters for the plugins from a file, e.g. a directive like "from_file" similar to the already existing "from_secret"? This is how one could use it:

kind: pipeline
name: default

steps:
- name: get_repo_name
  image: alpine
  commands:
  - echo "hello" > .repo_name
- name: docker  
  image: plugins/docker
  settings:
    repo: 
      from_file: .repo_name
    username:
      from_secret: docker_username
    password:
      from_secret: docker_password

Upvotes: 3

Views: 3494

Answers (1)

hikerspath
hikerspath

Reputation: 106

Ability to read input from a file is more the choice of the plugin author, but creating plugins is a pretty simplistic thing as most of your variables just have to be called in as PLUGIN_VARIABLE and you can then offer such things.

To show that some of the plugins do read from file, one such example is drone-github-comment:

steps:
- name: github-comment
  image: jmccann/drone-github-comment:1.2
  settings:
    message_file: file_name.txt
  when:
    status:
    - success
    - failure

FWIW, looking at your example though, it would seem you are looking to pass just the repo_name? These variables are all present in a pipeline depending of course on the runner you are using, but for Docker you get all of these:

Upvotes: 2

Related Questions