I want to stamp my docker images with the tag which I write to .tags in a previous step.
Basically I’d like to accomplish
build_args:
- BUILD_ID: $(cat .tags)
I want to stamp my docker images with the tag which I write to .tags in a previous step.
Basically I’d like to accomplish
build_args:
- BUILD_ID: $(cat .tags)
Is this possible in the latest release of drone?
You cannot use bash commands inside of yaml properties like this. bash commands can only be executed in the commands
section.
I didn’t mean to actually execute the bash command, I meant if there’s even a way to pass the content of .tags to the build_args
the .tags
file is tied to the tags
attribute in the yaml. it is not possible to use this file to populate other attributes.
Can you think of any workaround to stamp a custom build arg to an image?
Basically I want build-${DRONE_BUILD_NUMBER}
for regular builds and ${DRONE_TAG}
when it’s a tag push. I have logic to write that to .tags
but I need to stamp it onto the image as well.
you can do this:
- name: build
image: plugins/docker
settings:
tags: build-${DRONE_BUILD_NUMBER}
repo: ...
when:
event: [ push, pull_request ]
- name: build_tag
image: plugins/docker
settings:
tags: ${DRONE_TAG}
repo: ...
when:
event: [ tag ]
and if you need to keep things DRY you can use anchors.
This works like a charm and is so much neater than writing to .tags
. Thank you very much!