Hi,
Is there a p4 way for below ?
Please refer to https://jenkins.io/doc/tutorials/build-a-multibranch-pipeline-project/
There's expression like
```
stage('a') {
when
steps
How can I use for this in p4?
Hello Hokwang Lee,
I have just tested and this seems to work with a multibranch pipeline. In the following only the branch 'main' exists:
pipeline { agent any stages { stage('Checkout') { when { branch 'BRANCH_DOES_NOT_EXIST' } steps { echo 'Don't show this...' } } stage('Build') { when { branch 'main' } steps { echo 'Building...' } } stage('Test') { steps { echo 'Testing...' } } } }
The relevant output I get in the console log is:
[Pipeline] // stage [Pipeline] withEnv [Pipeline] { [Pipeline] stage [Pipeline] { (Checkout) Stage "Checkout" skipped due to when conditional [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Build) [Pipeline] echo Building... [Pipeline] } [Pipeline] // stage [Pipeline] stage [Pipeline] { (Test) [Pipeline] echo Testing... [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline
Note that the stage 'Checkout' is successfully skipped when I run this against 'main' because it is not 'BRANCH_DOES_NOT_EXIST'.
Seems to work.