Reputation: 3873
I have this file hierarchy as below
/
run_docker.sh
Dockerfile
.gitlab-ci.yml
And the content of my .gitlab-ci.yml
is as follows
stages:
- run_script
- build_image
run_script:
stage: run_script
script:
- echo "script is running"
build_image:
stage: run_docker
script:
- echo "building image"
These script
tags are some examples I have put here (not real values) and what I want is, I need to trigger only the build_image
job when I did a change ONLY to the Dockerfile
and it SHOULDN'T trigger the build_image
job.
How can I do this?
Upvotes: 0
Views: 214
Reputation: 116
I had a similar scenario, and I ended up using the following condition:
only:
variables:
- $CI_COMMIT_MESSAGE =~ /docker/
It is not exactly what you wanted, but it can do the job. Whenever I need to trigger docker image building job, I just mention [docker]
in my commit message.
Upvotes: 1