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

PipelineTriggersJobProperty / pipelineTriggers() - snippet generator and syntax doc fail

    Details

    • Similar Issues:

      Description

      I was looking to use the new ability to trigger builds from a multi-branch project on a schedule.

      To try to use it, I went to look for the docs for how to use it, but both the snippet generator and the doc failed.

      For example, when you go to try to generate the trigger with a schedule of "H/15 * * * *", it generated the following:

      properties [pipelineTriggers([]), [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], [$class: 'ThrottleJobProperty', categories: [], limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 0, maxConcurrentTotal: 0, paramsToUseForLimit: '', throttleEnabled: false, throttleOption: 'project']]

      So I then went to look at the pipeline syntax - but on that page, I then found the following:
      {{$class: 'PipelineTriggersJobProperty'
      triggers
      Array/List:
      java.lang.UnsupportedOperationException: do not know how to categorize attributes of type hudson.triggers.Trigger<?>
      }}

      I am also attaching a screenshot

        Attachments

          Issue Links

            Activity

            Hide
            gregcovertsmith Greg Smith added a comment -

            In the meantime, if anyone could give me an example of how you would configure a the project property "Build Periodically" – I would be appreciative.

            With no snippet generator or syntax docs, I can not seem to find how to do this in any documentation.

            Show
            gregcovertsmith Greg Smith added a comment - In the meantime, if anyone could give me an example of how you would configure a the project property "Build Periodically" – I would be appreciative. With no snippet generator or syntax docs, I can not seem to find how to do this in any documentation.
            Hide
            danielbeck Daniel Beck added a comment -

            Andrew Bayer Didn't you work in this area recently?

            Show
            danielbeck Daniel Beck added a comment - Andrew Bayer Didn't you work in this area recently?
            Hide
            abayer Andrew Bayer added a comment -

            I did - I'll dig into this.

            And in the meantime - Greg Smith - this should work for you:

            properties([pipelineTriggers([cron('H/15 * * * *')])])
            
            Show
            abayer Andrew Bayer added a comment - I did - I'll dig into this. And in the meantime - Greg Smith - this should work for you: properties([pipelineTriggers([cron( 'H/15 * * * *' )])])
            Hide
            gregcovertsmith Greg Smith added a comment -

            One other thing I'll mention: The ability to choose "Build after other projects build" in the pipeline triggers snippet generator seem to be missing.

            I'm not sure if this is related or not - but maybe there's some kind of conflict between that option and the other new pipeline triggers that cause the docs / snippet generator to fail?

            I know that option was available recently, and is now gone.

            Anyway — thought I would add a list of the current properties values that I can currently see in the snippet generator, in case that give some clue to issue.

            Show
            gregcovertsmith Greg Smith added a comment - One other thing I'll mention: The ability to choose "Build after other projects build" in the pipeline triggers snippet generator seem to be missing. I'm not sure if this is related or not - but maybe there's some kind of conflict between that option and the other new pipeline triggers that cause the docs / snippet generator to fail? I know that option was available recently, and is now gone. Anyway — thought I would add a list of the current properties values that I can currently see in the snippet generator, in case that give some clue to issue.
            Hide
            abayer Andrew Bayer added a comment -

            So the underlying issue seems to be the following, which shows up in the docs:

            java.lang.UnsupportedOperationException: do not know how to categorize attributes of type hudson.triggers.Trigger<?>
            

            I'll dig into this.

            Show
            abayer Andrew Bayer added a comment - So the underlying issue seems to be the following, which shows up in the docs: java.lang.UnsupportedOperationException: do not know how to categorize attributes of type hudson.triggers.Trigger<?> I'll dig into this.
            Hide
            abayer Andrew Bayer added a comment -

            So the JSON that gets sent by the snippet generator is:

            {
              "propertiesMap":   {
                "stapler-class-bag": "true",
                "org-jenkinsci-plugins-workflow-job-properties-PipelineTriggersJobProperty": {"hudson-triggers-TimerTrigger": {"spec": "@daily"}},
                "jenkins-model-BuildDiscarderProperty":     {
                  "specified": false,
                  "": "0",
                  "strategy":       {
                    "daysToKeepStr": "",
                    "numToKeepStr": "",
                    "artifactDaysToKeepStr": "",
                    "artifactNumToKeepStr": "",
                    "stapler-class": "hudson.tasks.LogRotator",
                    "$class": "hudson.tasks.LogRotator"
                  }
                },
                "org-jenkinsci-plugins-workflow-job-properties-DisableConcurrentBuildsJobProperty": {"specified": false},
                "hudson-model-ParametersDefinitionProperty": {"specified": false},
                "jenkins-branch-RateLimitBranchProperty$JobPropertyImpl": {}
              },
              "stapler-class": "org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep",
              "$class": "org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep"
            }
            

            Now to figure out why it isn't working - just wanted to get a record of the JSON for debugging purposes by anyone else. =)

            Show
            abayer Andrew Bayer added a comment - So the JSON that gets sent by the snippet generator is: { "propertiesMap" : { "stapler- class- bag" : " true " , "org-jenkinsci-plugins-workflow-job-properties-PipelineTriggersJobProperty" : { "hudson-triggers-TimerTrigger" : { "spec" : "@daily" }}, "jenkins-model-BuildDiscarderProperty" : { "specified" : false , "": " 0", "strategy" : { "daysToKeepStr" : "", "numToKeepStr" : "", "artifactDaysToKeepStr" : "", "artifactNumToKeepStr" : "", "stapler-class" : "hudson.tasks.LogRotator" , "$class" : "hudson.tasks.LogRotator" } }, "org-jenkinsci-plugins-workflow-job-properties-DisableConcurrentBuildsJobProperty" : { "specified" : false }, "hudson-model-ParametersDefinitionProperty" : { "specified" : false }, "jenkins-branch-RateLimitBranchProperty$JobPropertyImpl" : {} }, "stapler-class" : "org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep" , "$class" : "org.jenkinsci.plugins.workflow.multibranch.JobPropertyStep" } Now to figure out why it isn't working - just wanted to get a record of the JSON for debugging purposes by anyone else. =)
            Hide
            jglick Jesse Glick added a comment -

            Replace List<Trigger<?>> with List<Trigger> and @SuppressWarnings("rawtypes").

            Show
            jglick Jesse Glick added a comment - Replace List<Trigger<?>> with List<Trigger> and @SuppressWarnings("rawtypes") .
            Hide
            abayer Andrew Bayer added a comment -

            Ok, lemme try that.

            Show
            abayer Andrew Bayer added a comment - Ok, lemme try that.
            Hide
            abayer Andrew Bayer added a comment -

            That fixes the docs but not the snippet generator...

            Show
            abayer Andrew Bayer added a comment - That fixes the docs but not the snippet generator...
            Hide
            jglick Jesse Glick added a comment -

            Well the JSON looks messed up to me. The unusual propertiesMap is OK—see JobPropertyStep.DescriptorImpl.newInstance—but the JSON for PipelineTriggersJobProperty is junk. Probably your config.jelly needs to be redesigned. For starters, why is there no field set? The databinding is not being set up to define a List-valued property triggers.

            (Whatever you change, reconfigure will presumably need to be tweaked to match.)

            Probably you need to use StepConfigTester to verify that your databinding is valid.

            Show
            jglick Jesse Glick added a comment - Well the JSON looks messed up to me. The unusual propertiesMap is OK—see JobPropertyStep.DescriptorImpl.newInstance —but the JSON for PipelineTriggersJobProperty is junk. Probably your config.jelly needs to be redesigned. For starters, why is there no field set? The databinding is not being set up to define a List -valued property triggers . (Whatever you change, reconfigure will presumably need to be tweaked to match.) Probably you need to use StepConfigTester to verify that your databinding is valid.
            Hide
            abayer Andrew Bayer added a comment -

            shrug Beats me. I'll see what I can do.

            Show
            abayer Andrew Bayer added a comment - shrug Beats me. I'll see what I can do.
            Hide
            abayer Andrew Bayer added a comment -

            So I copy-pasted from the triggers config in core - I guess that won't work.

            Show
            abayer Andrew Bayer added a comment - So I copy-pasted from the triggers config in core - I guess that won't work.
            Hide
            abayer Andrew Bayer added a comment -

            PRs up in both workflow-job and workflow-multibranch - the latter is just a test, and will fail for now 'cos I can no longer deploy SNAPSHOTs of workflow-job due to changes in Artifactory permissions.

            Show
            abayer Andrew Bayer added a comment - PRs up in both workflow-job and workflow-multibranch - the latter is just a test, and will fail for now 'cos I can no longer deploy SNAPSHOTs of workflow-job due to changes in Artifactory permissions.
            Hide
            jglick Jesse Glick added a comment -

            Probably then need JENKINS-29711 as well.

            Show
            jglick Jesse Glick added a comment - Probably then need JENKINS-29711 as well.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java
            src/main/java/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty.java
            http://jenkins-ci.org/commit/workflow-job-plugin/df624fbb07df077e04b8acb84d2e604842584ca6
            Log:
            JENKINS-37477 - Partial fix - docs are generated now.

            Snippet generator still not working, so more work to do.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowJob.java src/main/java/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty.java http://jenkins-ci.org/commit/workflow-job-plugin/df624fbb07df077e04b8acb84d2e604842584ca6 Log: JENKINS-37477 - Partial fix - docs are generated now. Snippet generator still not working, so more work to do.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            src/main/resources/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty/config.jelly
            http://jenkins-ci.org/commit/workflow-job-plugin/0fcaff04e2982488ff895668ad62b80ecea949aa
            Log:
            [FIXED JENKINS-37477] Fixed the snippet generator.

            Test is in workflow-multibranch-plugin.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/main/resources/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty/config.jelly http://jenkins-ci.org/commit/workflow-job-plugin/0fcaff04e2982488ff895668ad62b80ecea949aa Log: [FIXED JENKINS-37477] Fixed the snippet generator. Test is in workflow-multibranch-plugin.
            Hide
            abayer Andrew Bayer added a comment -

            Fixed in about-to-release workflow-job plugin 2.6.

            Show
            abayer Andrew Bayer added a comment - Fixed in about-to-release workflow-job plugin 2.6.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/15aa0ae9be1867b7bc0911a2785000952df4d8ea
            Log:
            JENKINS-37477 - Demonstrate snippets not generating right for triggers

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/15aa0ae9be1867b7bc0911a2785000952df4d8ea Log: JENKINS-37477 - Demonstrate snippets not generating right for triggers
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStep.java
            src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/378631399ffb542c005723033f42b0af8b2e5e08
            Log:
            JENKINS-37477 Updating for SNAPSHOT of workflow-job.

            Which fixes doc generation, but not snippet generator.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStep.java src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/378631399ffb542c005723033f42b0af8b2e5e08 Log: JENKINS-37477 Updating for SNAPSHOT of workflow-job. Which fixes doc generation, but not snippet generator.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/debde517af80c551a86e17c14f7a6f2eb1ccab83
            Log:
            JENKINS-37477 Working test for snippet generator for triggers.

            Can't do round tripping due to JENKINS-29711, and StepConfigTester
            doesn't work due to this being a Pipeline-specific JobProperty, but
            the snippet generator test does what's expected.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/debde517af80c551a86e17c14f7a6f2eb1ccab83 Log: JENKINS-37477 Working test for snippet generator for triggers. Can't do round tripping due to JENKINS-29711 , and StepConfigTester doesn't work due to this being a Pipeline-specific JobProperty, but the snippet generator test does what's expected.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/c8494c01368a9641b0f768a37ccc8d57da1e7d6c
            Log:
            JENKINS-37477 Add a test for lack of failures in doc generation.

            Ignoring errors in re: lack of @DataBoundConstructor for now. That may
            change, but those are generally symptomatic of something so deep in
            the core that they're not worth worrying about at the moment.

            The guts of the test should probably move to workflow-cps for common
            usage, a la SnippetizerTester.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/c8494c01368a9641b0f768a37ccc8d57da1e7d6c Log: JENKINS-37477 Add a test for lack of failures in doc generation. Ignoring errors in re: lack of @DataBoundConstructor for now. That may change, but those are generally symptomatic of something so deep in the core that they're not worth worrying about at the moment. The guts of the test should probably move to workflow-cps for common usage, a la SnippetizerTester.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Andrew Bayer
            Path:
            pom.xml
            src/main/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStep.java
            src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/42c3b10d3e49fb1b41d3a2663610b2256bbdf055
            Log:
            Merge pull request #28 from abayer/jenkins-37477

            Test for JENKINS-37477

            Compare: https://github.com/jenkinsci/workflow-multibranch-plugin/compare/80120a5bbfb7...42c3b10d3e49

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Andrew Bayer Path: pom.xml src/main/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStep.java src/test/java/org/jenkinsci/plugins/workflow/multibranch/JobPropertyStepTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/42c3b10d3e49fb1b41d3a2663610b2256bbdf055 Log: Merge pull request #28 from abayer/jenkins-37477 Test for JENKINS-37477 Compare: https://github.com/jenkinsci/workflow-multibranch-plugin/compare/80120a5bbfb7...42c3b10d3e49

              People

              • Assignee:
                abayer Andrew Bayer
                Reporter:
                gregcovertsmith Greg Smith
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: