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

Pipeline Model: Add sections for build parameters, triggers and general build properties

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      We're currently blacklisting the properties step from usage within the model, and we're going to stay that way - it can cause waaaaay too much confusion when executed outside of a central control. But that means we need to provide configuration sections for job properties. I'd like to do that as three separate sections - one for each of build parameters, triggers and other job properties.

      My reasoning is that the catch-allness of properties is part of its confusion - you can only call it once per Jenkinsfile and you have to have every JobProperty you care about defined in it. I want to add a layer of abstraction over that - the three groupings (parameters, triggers, misc) make sense as three separate sections with different syntax.

        Attachments

          Issue Links

            Activity

            Hide
            abayer Andrew Bayer added a comment -

            Marking this as depending on JENKINS-38285 since this is a good opportunity to make the config sections an ExtensionPoint.

            Show
            abayer Andrew Bayer added a comment - Marking this as depending on JENKINS-38285 since this is a good opportunity to make the config sections an ExtensionPoint .
            Hide
            abayer Andrew Bayer added a comment -

            No longer dependent on JENKINS-38285 since I don't think that's going to happen.

            Show
            abayer Andrew Bayer added a comment - No longer dependent on JENKINS-38285 since I don't think that's going to happen.
            Hide
            abayer Andrew Bayer added a comment -

            So what I'm trying to figure out here is how to define the properties in their separate sections and translate that into a list of parameters to properties(...). If the properties were all literals, well, that'd be fine. But that'd suck - we want symbols, meaning we want, effectively, lazily evaluated method calls. I have some vague ideas on that front at the moment, but need to keep experimenting to find what might actually work.

            Show
            abayer Andrew Bayer added a comment - So what I'm trying to figure out here is how to define the properties in their separate sections and translate that into a list of parameters to properties(...) . If the properties were all literals, well, that'd be fine. But that'd suck - we want symbols, meaning we want, effectively, lazily evaluated method calls. I have some vague ideas on that front at the moment, but need to keep experimenting to find what might actually work.
            Hide
            abayer Andrew Bayer added a comment -

            So the best bet I've come up with so far is to translate something like:

            triggers {
              cron('@daily')
            }
            
            properties {
              buildDiscarder(logRotator(numToKeepStr: '1'))
              disableConcurrentBuilds()
            }
            

            into a quasi-AST that we can then re-assemble and invoke at runtime. If I could somehow tease each line out into their own closures directly, then we'd be good to go, but I don't see a way to do that currently. And something more like buildDiscarder logRotator(numToKeepStr: '1') (i.e., the syntax we use for tools, agent, etc) doesn't work because logRotator(numToKeepStr: '1') ends up being invoked at parse/config-time. The delegate-fallback approach used in the environment section doesn't, I think, work right here due to the fact that the symbol resolution only works in the right context.

            Soooooo. More experimentation to come.

            Show
            abayer Andrew Bayer added a comment - So the best bet I've come up with so far is to translate something like: triggers { cron( '@daily' ) } properties { buildDiscarder(logRotator(numToKeepStr: '1' )) disableConcurrentBuilds() } into a quasi-AST that we can then re-assemble and invoke at runtime. If I could somehow tease each line out into their own closures directly, then we'd be good to go, but I don't see a way to do that currently. And something more like buildDiscarder logRotator(numToKeepStr: '1') (i.e., the syntax we use for tools , agent , etc) doesn't work because logRotator(numToKeepStr: '1') ends up being invoked at parse/config-time. The delegate-fallback approach used in the environment section doesn't, I think, work right here due to the fact that the symbol resolution only works in the right context. Soooooo. More experimentation to come.
            Show
            abayer Andrew Bayer added a comment - PR #27 - https://github.com/jenkinsci/pipeline-model-definition-plugin/pull/27
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pom.xml
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTBuildParameter.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTBuildParameters.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTElement.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperties.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperty.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTKeyValueOrMethodCallPair.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTMethodArg.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTMethodCallFromArguments.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPositionalArgumentList.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTTrigger.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTTriggers.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTValue.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/JobProperties.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/MethodsToList.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Parameters.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Tools.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Triggers.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy
            src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.groovy
            src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ModelStepLoader.java
            src/main/resources/ast-schema.json
            src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy
            src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/MethodsToListTranslator.groovy
            src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy
            src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java
            src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/JobPropertiesTest.java
            src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ParametersTest.java
            src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/TriggersTest.java
            src/test/resources/json/simpleJobProperties.json
            src/test/resources/json/simpleParameters.json
            src/test/resources/json/simpleTriggers.json
            src/test/resources/simpleJobProperties.groovy
            src/test/resources/simpleParameters.groovy
            src/test/resources/simpleTriggers.groovy
            http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f533ef99e31ce44cbe999653e538ea39fdf772dc
            Log:
            [FIXED JENKINS-37824] Adding job property-related functionality

            More specifically, added "jobProperties", "parameters" and "triggers"
            section and related functionality.

            This required some fairly complex logic for translating something like
            "buildDiscarder(logRotator(numToKeepStr:'1'))" in the config into
            something that can do what we need at runtime. Hooray complexity!

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/Utils.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTBuildParameter.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTBuildParameters.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTElement.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperties.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTJobProperty.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTKeyValueOrMethodCallPair.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTMethodArg.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTMethodCallFromArguments.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPipelineDef.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTPositionalArgumentList.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTTrigger.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTTriggers.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/ast/ModelASTValue.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/JobProperties.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/MethodsToList.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Parameters.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Root.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Tools.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/model/Triggers.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/JSONParser.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/validator/ModelValidator.groovy src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/ModelStepLoader.java src/main/resources/ast-schema.json src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ClosureModelTranslator.groovy src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/MethodsToListTranslator.groovy src/main/resources/org/jenkinsci/plugins/pipeline/modeldefinition/ModelInterpreter.groovy src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/AbstractModelDefTest.java src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/JobPropertiesTest.java src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/ParametersTest.java src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/TriggersTest.java src/test/resources/json/simpleJobProperties.json src/test/resources/json/simpleParameters.json src/test/resources/json/simpleTriggers.json src/test/resources/simpleJobProperties.groovy src/test/resources/simpleParameters.groovy src/test/resources/simpleTriggers.groovy http://jenkins-ci.org/commit/pipeline-model-definition-plugin/f533ef99e31ce44cbe999653e538ea39fdf772dc Log: [FIXED JENKINS-37824] Adding job property-related functionality More specifically, added "jobProperties", "parameters" and "triggers" section and related functionality. This required some fairly complex logic for translating something like "buildDiscarder(logRotator(numToKeepStr:'1'))" in the config into something that can do what we need at runtime. Hooray complexity!

              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: