Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-37823

Pipeline Model: Add a "wrappers" section

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      We should add a "wrappers" section for specifying things like withCredentials, timeout and the like across the entire build rather than just within the steps for a given stage.

      A couple notes - this will need to only be for block-scoped Pipeline steps, not for BuildWrapper, since the latter require a node context. And this'll be a little tricky to implement since we want to be able to specify a wrapper step and any of its arguments and then invoke each of those steps with the rest of the build (including subsequent wrapper steps) in a closure passed to those steps...

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Started work on this, but it's harder to get a good way to translate the syntax to translate at runtime than you might think. I put this down for a couple days to let my mind subconsciously stew on it for a bit. =)

            Show
            abayer Andrew Bayer added a comment - Started work on this, but it's harder to get a good way to translate the syntax to translate at runtime than you might think. I put this down for a couple days to let my mind subconsciously stew on it for a bit. =)
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
            pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java
            pipeline-model-definition/src/test/resources/errors/pipelineStepWithinOtherBlocksFailure.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f25d40a2a5ffe0469ce80b070610d07fcdd3bb2a
            Log:
            [FIXED JENKINS-39011] Error out at parse time when pipeline step is nested.

            We don't want to support nesting the pipeline step within other blocks

            • until JENKINS-38152, we never noticed that this was actually
              possible, since the parse-time validation just ignored any Jenkinsfile
              without a root-level pipeline step, but with JENKINS-38152, we not
              only do another parse round but need to grab the stages from the model
              to attach to the run, so we hit an NPE when there's a pipeline step
              nested under other blocks.

            So - this will now catch when the pipeline step is nested within
            another block and give an error message at parse-time, rather than
            NPEing at runtime. There is a valid use case for wanting to wrap the
            entire build in something like a timeout or timestamper, but we're
            going to address that with JENKINS-37823.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ValidatorTest.java pipeline-model-definition/src/test/resources/errors/pipelineStepWithinOtherBlocksFailure.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f25d40a2a5ffe0469ce80b070610d07fcdd3bb2a Log: [FIXED JENKINS-39011] Error out at parse time when pipeline step is nested. We don't want to support nesting the pipeline step within other blocks until JENKINS-38152 , we never noticed that this was actually possible, since the parse-time validation just ignored any Jenkinsfile without a root-level pipeline step, but with JENKINS-38152 , we not only do another parse round but need to grab the stages from the model to attach to the run, so we hit an NPE when there's a pipeline step nested under other blocks. So - this will now catch when the pipeline step is nested within another block and give an error message at parse-time, rather than NPEing at runtime. There is a valid use case for wanting to wrap the entire build in something like a timeout or timestamper, but we're going to address that with JENKINS-37823 .
            Show
            abayer Andrew Bayer added a comment - PR up for review at https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/36
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            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/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-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.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/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/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.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/resources/errors/invalidWrapperType.groovy
            pipeline-model-definition/src/test/resources/json/errors/invalidWrapperType.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/multipleWrappers.groovy
            pipeline-model-definition/src/test/resources/simpleWrapper.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/b01db8aa6e692e06c8228e0891ca8f06aac4aa02
            Log:
            [FIXED JENKINS-37823] Added "wrappers" section.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: 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/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-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.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/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/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.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/resources/errors/invalidWrapperType.groovy pipeline-model-definition/src/test/resources/json/errors/invalidWrapperType.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/multipleWrappers.groovy pipeline-model-definition/src/test/resources/simpleWrapper.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/b01db8aa6e692e06c8228e0891ca8f06aac4aa02 Log: [FIXED JENKINS-37823] Added "wrappers" section.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            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/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-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.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/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/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.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/resources/errors/invalidWrapperType.groovy
            pipeline-model-definition/src/test/resources/json/errors/invalidWrapperType.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/multipleWrappers.groovy
            pipeline-model-definition/src/test/resources/simpleWrapper.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/91f0ec0f5283f0f163378773ee8cdbf74953fa71
            Log:
            Merge pull request #36 from abayer/jenkins-37823-mk2

            [FIXED JENKINS-37823] Added "wrappers" section.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: 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/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-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.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/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/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.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/resources/errors/invalidWrapperType.groovy pipeline-model-definition/src/test/resources/json/errors/invalidWrapperType.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/multipleWrappers.groovy pipeline-model-definition/src/test/resources/simpleWrapper.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/91f0ec0f5283f0f163378773ee8cdbf74953fa71 Log: Merge pull request #36 from abayer/jenkins-37823-mk2 [FIXED JENKINS-37823] Added "wrappers" section.

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                abayer Andrew Bayer
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: