so-random-dude
so-random-dude

Reputation: 16505

How to transfer a value from one build container to another in drone.io CI pipeline

I know I can write it to the mounted host file system which will be shared amongst the multiple build containers. But how can I make use of that file in a drone plugin container like docker-plugin?

Or, is there any other way to pass arbitrary data between build steps? Maybe through environment variables?

This is drone 0.5

Upvotes: 1

Views: 2689

Answers (1)

Brad Rydzewski
Brad Rydzewski

Reputation: 2563

It is only possible to share information between build steps via the filesystem. Environment variable are not an option because there is no clean way to share environment variables between sibling unix processes.

It is the responsibility of the plugin to decide how it wants to accept configuration parameters. Usually parameters are passed to the plugin as environment variables, defined in the yaml configuration file. Some plugins, notably the docker plugin [1], have the ability to read parameters from file. For example, the docker plugin will read docker tags from a .tags file in the root of your repository, which can be generated on the fly.

pipeline:
  build:
    image: golang
    commands:
      - go build
      - echo ${DRONE_COMMIT:0:8} > .tags
  publish:
    image: plugins/docker
    repo: octocat/hello-world

Not all plugins provide the option to read parameters from file. It is up to the plugin author to include this capability. If the plugin does not have this capability, or it is not something the plugin author is planning to implement, you can always fork and adjust the plugin to meet your exact needs.

[1] https://github.com/drone-plugins/drone-docker

Upvotes: 5

Related Questions