-
Story
-
Resolution: Done
-
Minor
-
None
-
Pipeline Config 0.1
-
Powered by SuggestiMate
A common enough pattern is to skip either a whole pipeline or a stage based on the branch of execution. This is pretty common in deployment focused pipelines, and would be a strong reason to break out of config and that would be a shame.
It would be nice if this was somewhat first class in pipeline config. Some may be able to be done with a block scoped step... but not clear if all can be.
A general way of saying "if this boolean condition is false, skip this stage" would be the way to go - a branch matching would be one particular use of this, but the right thing to do is go generic.
- is related to
-
JENKINS-47286 Support skipping stages in scripted pipelines for nice visualization in blue ocean and classic UI stage view
-
- Closed
-
[JENKINS-37781] Pipeline Config: ability to skip whole pipeline or stages based on boolean condition
Well, we'd still "run" the stage - we just wouldn't actually do anything in it, like we now do with stages after a failed stage, so that we preserve the execution plan regardless of status.
As pointed out above by Anton, showing it as "Successful", "Failed", or "Unstable" wouldn't be entirely accurate.
Also, would this skip the "post" actions entirely as well?
As of now, there's no way to set a stage to a specific status, so it'll just be whatever the overall status is.
I'd say yes, we would skip post-stage actions as well.
hrmpw abayer what if "skipped" stages were not displayed at all? However, if we did want skipped stages to show we should introduce a skipped state.
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTScriptBlock.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhen.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WhenStageTest.java
pipeline-model-definition/src/test/resources/simpleWhen.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/dfab9e247559bf258b0aa35e4160cc91b45e0abc
Log:
JENKINS-37781 Adding Stage.when to specify if a stage should run or not
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WhenStageTest.java
pipeline-model-definition/src/test/resources/simpleWhen.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/9676206a2bc0ec8b93624ae8fc7cf907e8273b4e
Log:
JENKINS-37781 fixing the compilation of the compiler
and cleaned up some debug echo
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhen.java
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/resources/ast-schema.json
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WhenStageTest.java
pipeline-model-definition/src/test/resources/simpleWhen.groovy
pipeline-model-definition/src/test/resources/when/simpleWhen.groovy
pipeline-model-definition/src/test/resources/when/whenEmpty.groovy
pipeline-model-definition/src/test/resources/when/whenException.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/819bbdfeb1ba3a6351baf142a558bb5ccdc599af
Log:
JENKINS-37781 More tests
Fixed some issues those tests revealed.
Also fixed a bug where the last line of a script or when closure wasn't parsed
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/eddf70b8c5747b8c516752e8c033891b6cfc9daa
Log:
JENKINS-37781 Fixed empty when validation
It would be awesome to have such functionally!
From my point of view having DSL like: stage(name: "My Stage", skip: true) would be good enough. If a stage is skipped make it gray on the board.
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-api/pom.xml
pipeline-model-declarative-agent/pom.xml
pipeline-model-definition/pom.xml
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
pom.xml
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/b8463d5ab69d6ae10871d80892150fa04d323d82
Log:
Merge branch 'master' of github.com:jenkinsci/pipeline-model-definition-plugin into JENKINS-37781
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/AbstractModelASTCodeBlock.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTScriptBlock.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhen.java
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/efe93beefe8be357adc0cab0e2d319a05502fcda
Log:
JENKINS-37781 Split ModelASTScriptBlock and ModelASTWhen
Into having one common ancestor instead of when extending script
Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/d65d3dc3117f...efe93beefe8b
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-declarative-agent/pom.xml
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgent.java
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentDescriptor.java
pipeline-model-definition/pom.xml
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/AbstractBuildConditionResponder.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Agent.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/JobProperties.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/MappedClosure.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/NestedModel.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Parameters.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stages.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/StepsBlock.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Tools.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Triggers.groovy
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ModelStepLoader.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipeline.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfile.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Label.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/model/BuildCondition.java
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineFromDockerfileScript.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelAndOtherFieldAgent.java
pipeline-model-definition/src/test/resources/fromAlternateDockerfile.groovy
pipeline-model-definition/src/test/resources/fromDockerfile.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/8c766601a1394bc2f5652c7a5fd8c6497563f265
Log:
Merge remote-tracking branch 'origin/master' into JENKINS-37781
Conflicts:
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/efe93beefe8b...8c766601a139
Code changed in jenkins
User: Robert Sandell
Path:
README.md
SYNTAX.md
pipeline-model-api/pom.xml
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStep.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWrapper.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWrappers.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
pipeline-model-declarative-agent/pom.xml
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgent.java
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentDescriptor.java
pipeline-model-declarative-agent/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/DeclarativeAgentScript.java
pipeline-model-definition/pom.xml
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Agent.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Wrappers.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/WrappersToMap.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Any.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipeline.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/Label.java
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/None.java
pipeline-model-definition/src/main/resources/ast-schema.json
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/WrappersToMapTranslator.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/DockerPipelineScript.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelScript.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/NoneScript.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AgentTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/EnvironmentTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ToolsTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WrappersTest.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelAndOtherFieldAgent.java
pipeline-model-definition/src/test/resources/agentAnyInStage.groovy
pipeline-model-definition/src/test/resources/agentTypeOrdering.groovy
pipeline-model-definition/src/test/resources/environmentInStage.groovy
pipeline-model-definition/src/test/resources/errors/agentMissingRequiredParam.groovy
pipeline-model-definition/src/test/resources/errors/agentUnknownParamForType.groovy
pipeline-model-definition/src/test/resources/errors/invalidWrapperType.groovy
pipeline-model-definition/src/test/resources/errors/unknownAgentType.groovy
pipeline-model-definition/src/test/resources/errors/unknownBareAgentType.groovy
pipeline-model-definition/src/test/resources/json/agentTypeOrdering.json
pipeline-model-definition/src/test/resources/json/environmentInStage.json
pipeline-model-definition/src/test/resources/json/errors/agentMissingRequiredParam.json
pipeline-model-definition/src/test/resources/json/errors/agentUnknownParamForType.json
pipeline-model-definition/src/test/resources/json/errors/invalidWrapperType.json
pipeline-model-definition/src/test/resources/json/errors/unknownAgentType.json
pipeline-model-definition/src/test/resources/json/errors/unknownBareAgentType.json
pipeline-model-definition/src/test/resources/json/multipleWrappers.json
pipeline-model-definition/src/test/resources/json/simpleWrapper.json
pipeline-model-definition/src/test/resources/json/toolsInStage.json
pipeline-model-definition/src/test/resources/multipleWrappers.groovy
pipeline-model-definition/src/test/resources/org/jenkinsci/plugins/pipeline/modeldefinition/agent/impl/LabelAndOtherFieldAgentScript.groovy
pipeline-model-definition/src/test/resources/simpleWrapper.groovy
pipeline-model-definition/src/test/resources/toolsInStage.groovy
pom.xml
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/d65d3dc3117f30a4502cfa7ad48c7494b9c0915d
Log:
Merge branch 'master' of github.com:jenkinsci/pipeline-model-definition-plugin into JENKINS-37781
Conflicts:
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
Code changed in jenkins
User: Robert Sandell
Path:
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/AbstractModelASTCodeBlock.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTScriptBlock.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTStage.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTWhen.java
pipeline-model-api/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.java
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Stage.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidatorImpl.groovy
pipeline-model-definition/src/main/resources/ast-schema.json
pipeline-model-definition/src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/WhenStageTest.java
pipeline-model-definition/src/test/resources/when/simpleWhen.groovy
pipeline-model-definition/src/test/resources/when/whenEmpty.groovy
pipeline-model-definition/src/test/resources/when/whenException.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/ec6f0ea92278c82b854b65710d4fc0e8f65f3413
Log:
Merge pull request #41 from jenkinsci/JENKINS-37781
JENKINS-37781 Adding Stage.when to specify if a stage should run
Compare: https://github.com/jenkinsci/pipeline-model-definition-plugin/compare/eee41f81b547...ec6f0ea92278
rsandell do you know what skipped sections look like as far as the Blue Ocean visualisation goes?
Code changed in jenkins
User: Robert Sandell
Path:
SYNTAX.md
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/71c3d60ee486e48757bbd76315dc69a9e0418775
Log:
Update SYNTAX.md
Noting changes introduced in JENKINS-37792, JENKINS-37781 and JENKINS-37778
Also fixed the script example and marked the code sections as groovy
so that GitHub hopefully can color the code a bit more nicely.
hrmpw not sure if this was documented? May have slipped through the cracks.
Is this a blue ocean only thing?
I'm wondering if there is a "skipped" state in plain Pipeline DSL / Stage View Plugin, but haven't found it yet...
Also not clear how to use it in the DSL. Can you point me to an example?
*update: * found the docs:
https://github.com/jenkinsci/pipeline-model-definition-plugin/commit/71c3d60ee486e48757bbd76315dc69a9e0418775#diff-fa1a1fd4274e733b635b3978b3d39ce6R88
Is skipped available for pipelines that don't use the pipeline model definition plugin ?
jamesdumay the ways I can think of are:
if(condition) { stage('myStage') { // things } }
Which causes it to not show up if the condition is false (at least in the Pipeline Stage View Plugin. With that view, it also has some weird display issues if new pipelines have different stage executions than previous ones.
The other option is to:
stage('myStage') { if(condition) { // things } }
This case seems to always mark it has a successful stage (haven't looked at actual status).
*Note: *We haven't updated to the Blue Ocean 1.0 yet, and have not made concerted efforts for the pipeline model to see how well it will work for us
mkobit I'd so something like this to make it clear that the stage was skipped but it would keep the stage itself as successful.
stage('myStage') { if(condition) { // steps } else { echo 'Skipped' } }
I know this was closed, but I would like to be able to mark the stages in a scripted pipeline as skipped to get the same visual benefits in https://issues.jenkins-ci.org/browse/JENKINS-39628 . Nobody in our organization uses the Pipeline Model plugin yet, and will most likely not switch for a while.
Sorry mkobit - for the time being the nice new visualisation bells and whistles will be declarative only
jamesdumay Is there a ticket that I could watch/vote for adding this to the scripted pipeline?
Ad comments/requests from mkobit and msrylander: I'd be happy about that too, especially since due to https://issues.jenkins-ci.org/browse/JENKINS-46547 most non-straightforward declarative pipelines in shared libraries need to be converted into scripted pipelines...
msrylander there isn't a ticket for supporting this in scripted pipeline.
=> therefore filed https://issues.jenkins-ci.org/browse/JENKINS-47286 "Support skipping stages in scripted pipelines for nice visualization in blue ocean and classic UI stage view"
jamesdumay rsandell I see this ticket is resolved and wonder when and what release will it out? Could you guys please answer it? Thanks
It's "resolved" as POSTPONED. So it's not fixed. Also, closing issues like that doesn't allow people to vote for them, which kind of sucks (I've seen it for other issues like supporting labels to steps).
Sorry, I think I got the comments mixed up, I was replying about scripted pipelines:
=> therefore filed https://issues.jenkins-ci.org/browse/JENKINS-47286 "Support skipping stages in scripted pipelines for nice visualization in blue ocean and classic UI stage view"
It is easy enough to skip a stage with an if block, but then the view of that pipeline gets cleared every time the number of stages changes. It would be nice to report a stage as N/A or skipped, and perhaps have it coloured white to show clearly that it wasn't actually run during this particular build.