I have following gitlab-ci conf. file:
before_script:
- echo %CI_BUILD_REF%
- echo %CI_PROJECT_DIR%
stages:
- createPBLs
- build
- package
create PBLs:
stage: createPBLs
script:
- xcopy /y /s "%CI_PROJECT_DIR%" "C:\Bauen\"
- cd "C:\Bauen\"
- ./run_orcascript.cmd
build:
stage: build
script:
- cd "C:\Bauen\"
- ./run_pbc.cmd
except:
- master
build_master:
stage: build
script:
- cd "C:\Bauen\"
- ./run_pbcm.cmd
only:
- master
package:
stage: package
script:
- cd "C:\Bauen\"
- ./cpfiles.cmd
artifacts:
expire_in: 1 week
name: "%CI_COMMIT_REF_NAME%"
paths:
- GitLab-Build
How can I add the rule that the pipeline will ONLY trigger if a new tag has been added to a branch? The tag should start with "Ticket/ticket_"
Currently he is building for every push.
GitLab CI/CD Trigger is the most common and convenient technique for triggering CI/CD. GitLab CI/CD pipelines, by default, are executed automatically when new commits are pushed to a repository and do not require any intervention once created.
Go to Settings → CI/CD → Pipeline triggers → Add Trigger . It will create a trigger with a TOKEN string, which then can be copied into the curl command of gitlab-ci. yml of project A. Note: The triggers under only is necessary to define the rules.
Create a new merge request from a source branch with one or more commits. Push a new commit to the source branch for a merge request. Select Run pipeline from the Pipelines tab in a merge request.
If a runner with this tag associated is available, it will pickup the job. In Git, within your repository, tags are used to mark a specific commit. It is often used to tag a version. The two concepts can be mixed up when you use tags (in Git) to start your pipeline in GitLab CI.
You need to use only syntax:
only:
- tags
This would trigger for any Tag
being pushed. If you want to be a bit more specific you can do:
only:
- /Ticket\/ticket\_.*/
which would build for any push with the Ticket/ticket_
tag.
below could be more readable, see only:varibles@gitlab-ci docs with refs:tags
only:
refs:
- tags
variables:
- $CI_COMMIT_TAG =~ /^[Tt]icket-.*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With