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

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

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • Jenkins 2.18
      Latest plugins installed as of 8-17-16

      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

          [JENKINS-37477] PipelineTriggersJobProperty / pipelineTriggers() - snippet generator and syntax doc fail

          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.

          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.

          Daniel Beck added a comment -

          abayer Didn't you work in this area recently?

          Daniel Beck added a comment - abayer Didn't you work in this area recently?

          Andrew Bayer added a comment -

          I did - I'll dig into this.

          And in the meantime - gregcovertsmith - this should work for you:

          properties([pipelineTriggers([cron('H/15 * * * *')])])
          

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

          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.

          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.

          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.

          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.

          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. =)

          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. =)

          Jesse Glick added a comment -

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

          Jesse Glick added a comment - Replace List<Trigger<?>> with List<Trigger> and @SuppressWarnings("rawtypes") .

          Andrew Bayer added a comment -

          Ok, lemme try that.

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

          Andrew Bayer added a comment -

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

          Andrew Bayer added a comment - That fixes the docs but not the snippet generator...

          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.

          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.

          Andrew Bayer added a comment -

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

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

          Andrew Bayer added a comment -

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

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

          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.

          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.

          Jesse Glick added a comment -

          Probably then need JENKINS-29711 as well.

          Jesse Glick added a comment - Probably then need JENKINS-29711 as well.

          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.

          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.

          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.

          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.

          Andrew Bayer added a comment -

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

          Andrew Bayer added a comment - Fixed in about-to-release workflow-job plugin 2.6.

          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

          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

          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.

          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.

          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.

          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.

          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.

          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.

          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

          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

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

              Created:
              Updated:
              Resolved: