Not sure if there’s a clean way to do this, but I’d like to be able to have my initial plugin configure the environment (e…g, ~/.gitconfig, .netrc, etc) for all subsequent plugins.
The way I thought to do this was to mount /root
in the initial and in the subsequent plugins, which would be a tmp directory (or cache) on the host (I assume that plugins mount the host machine, not the host container like the agent).
Alternatively, I could pre-configure the host machine or the host container with the data I want and mount that as /root
in the plugins that I want to use it.
Anyone doing something like this?
yes, in this case sounds like you could use the (new) temporary mount feature:
https://docs.drone.io/config/pipeline/volumes/#temporary-mounts
kind: pipeline
name: default
steps:
- name: foo
image: alpine
volumes:
- name: home
path: /root
commands:
- touch /root/hello.txt
- name: bar
image: alpine
volumes:
- name: home
path: /root
commands:
- ls -la /root
volumes:
- name: home
temp: {}
Yep, that worked well with a custom clone (as the clone needs this root volume)
@bradrydzewski, is this cleared for every pipeline in the yaml?
kind: pipeline
name: one
steps:
- name: foo
image: alpine
volumes:
- name: home
path: /root
commands:
- touch /root/hello.txt
volumes:
- name: home
temp: {}
---
kind: pipeline
name: two
depends_on:
- one
steps:
- name: bar
image: alpine
volumes:
- name: home
path: /root
commands:
- ls -la /root
volumes:
- name: home
temp: {}
Yep. The temporary volume is basically just a docker volume create
. The volume is created at the beginning of the pipeline and destroyed at the end. Under the covers volumes are namespaced to avoid collision. So in your above example, two volumes would be created (and destroyed).