An additional condition can be included in the same Gitlab Pipeline rule by making use of a reference using the "needs" keyword.
For example, let's say we have two stages in our pipeline: "build" and "test". We want the "test" stage to only run if the "build" stage succeeds and if the branch being built is "master". We can do this by adding a reference to the "build" stage in the "test" stage using the "needs" keyword.
Here's an example:
stages:
- build
- test
build:
stage: build
script:
- # Build script here
test:
stage: test
needs:
- job: build
branch: master
script:
- # Test script here
In the "test" stage, we added a "needs" keyword that references the "build" stage job and specifies a branch condition. This means that the "test" stage will only run if the "build" stage job succeeds and if the branch being built is "master".
By using references like this, we can create more complex pipeline rules with multiple conditions that need to be satisfied before a job can run.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-05-12 08:03:07 +0000
Seen: 9 times
Last updated: May 12 '23
What modifications can be made to this condition in order to substitute infinite and NaN values?
What is the time complexity of this code when it includes a conditional statement?
How can we make the for loop pause until we receive a signal for the next item?
What is the condition to prevent the deletion of folders containing files?
What does it mean when the if block is not being executed?
In R, how can the difference between dates be computed with a given condition?
Can you describe an Active Directory login script that includes a condition?
How can I apply OR condition between dimensions in Dynamics Row Level Security?