Run pipeline with condition
Create multiple stages
To add a shell script plug-in, enter any script: echo 1
Add a parallel stage
add a new stage
Add a finally stage Finally stage: The last step in the pipeline execution. The steps defined in the finally stage are executed whether the pipeline execution fails or succeeds
Scenario: After the preceding pipeline is configured, if a service requirement exists, only 2-1 jobs are executed and 2-2 and 3-1 are skipped if certain conditions are met Achieved by configuring variables
To define pipeline variables, click trigger and define test1 and test2
Configure Job 2-1, select 【Run only when all user-defined variables are met】, and enter two user-defined variables, test1 and test2, whose values are the same as those defined by trigger
Configure Job 2-2, click 2-2 Linux, select 【Run only when all user-defined variables are satisfied】, enter the two variables test1 and test2 that have just been customized, and write the values as you like, which are different from those defined by the trigger just now
Configure the 3-1 stage, select 【Run only when all user-defined variables are satisfied】, input the two variables test1 and test2 that have just been customized, and write the values arbitrarily, which are different from those defined by the trigger just now Note: Pipelining can be configured for stage/Job/ plug-in execution conditions
start pipeline, test1 and test2 variables with default values
View the execution result. You can see that 2-2Job and stage3 are skipped because variable conditions are not met
Last updated