问题
I have a gitlab pipeline which has two stages as shown below:
Below is my current .gitlab-ci.yml
:
stages:
- build
- push
build:
image: docker.repo.test.data/stuff/something:latest
variables:
LEGACY_VERSION: 10000
before_script:
- export CI_PIPE_ID=`expr $CI_PIPE_ID + $OLDER_VERSION`
script:
- echo "Building Project"
- ls -lrth
- ./build-project
push:
stage: push
image: docker.repo.test.data/stuff/something:latest
only:
- master
script:
- some stuff here
In my build
stage I try to build my project and in push
stage I try to push it. My push
stage only happens if any PR gets merged to master branch or any commit gets added to master branch as I am using only
there.
Problem Statement
Now I want to run my build
stage for below things as well:
- If someone creates a branch from master which starts with
release-xxx
name then I want to run onlybuild
stage. - If someone creates a branch from a particular commit which starts with
release-xxx
name then I want to run onlybuild
stage. - And for all other cases it should run build stage just like it is doing currently in my original
.gitlab-ci.yml
file.
Is this possible to do by any chance? Right now whenever I create a branch from master
it doesn't run build
stage.
来源:https://stackoverflow.com/questions/65604509/how-to-run-build-stage-in-gitlab-pipeline-on-branch-creation