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

PipelineJob trigger deprecation, migration error

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • job-dsl-plugin
    • None
    • Jenkins LTS 2.204.5, job-dsl-plugin 1.77, pipeline job 2.37
    • job-dsl-plugin 1.78

      Migration page for 1.77 deprecates pipeline trigger, so trying to migrate to new syntax. 

      Change my jobs from:
      triggers {
        cron('@daily')
      }

      To:
      properties {
      pipelineTriggers {
      triggers

      { cron('@daily') }

      }
      }

      DSL processing now fails with:
      13:02:42 ERROR: (fullbyacct.groovy, line 8) No signature of method: javaposse.jobdsl.plugin.structs.DescribableListContext.cron() is applicable for argument types: (java.lang.String) values: [@daily]
      13:02:42 Possible solutions: grep(), print(java.io.PrintWriter), print(java.lang.Object), grep(java.lang.Object), wait(), find()

      Am I missing something?

          [JENKINS-61463] PipelineJob trigger deprecation, migration error

          daspilker, it seems the `pipelineTriggers` is not part of reference documentation: https://jenkinsci.github.io/job-dsl-plugin/#path/javaposse.jobdsl.dsl.DslFactory.pipelineJob-properties. It works correctly for the Jenkins "live" reference doc

          Oliver Gondža added a comment - daspilker , it seems the `pipelineTriggers` is not part of reference documentation:  https://jenkinsci.github.io/job-dsl-plugin/#path/javaposse.jobdsl.dsl.DslFactory.pipelineJob-properties. It works correctly for the Jenkins "live" reference doc

          Same issue for Bitbucket server as well

          properties {
              pipelineTriggers {
                  triggers {
                      bitbucketTriggers {
                          repositoryServerPushAction(false, false, "")
                          pullRequestServerMergedAction()
                      }
                  }
              }
          } 

          Gnanasekaran Gajendiran added a comment - Same issue for Bitbucket server as well properties { pipelineTriggers { triggers { bitbucketTriggers { repositoryServerPushAction( false , false , "") pullRequestServerMergedAction() } } } }

          olivergondza "pipelineTriggers" is provided by Dynamic DSL, which is not shown in the static API viewer. Use the API viewer in your Jenkins installation. See https://github.com/jenkinsci/job-dsl-plugin/wiki/Dynamic-DSL.

          Daniel Spilker added a comment - olivergondza "pipelineTriggers" is provided by Dynamic DSL, which is not shown in the static API viewer. Use the API viewer in your Jenkins installation. See https://github.com/jenkinsci/job-dsl-plugin/wiki/Dynamic-DSL .

          Can someone provide a complete but minimal DSL script that reproduces the problem? Please also mention the minimal set of plugins that need to be installed.

          Daniel Spilker added a comment - Can someone provide a complete but minimal DSL script that reproduces the problem? Please also mention the minimal set of plugins that need to be installed.

          Gnanasekaran Gajendiran added a comment - - edited

          daspilker Thanks. This works fine.

          pipelineJob ("TestJob") {
              properties {
                  pipelineTriggers {
                      triggers {
                          pollSCM {
                              scmpoll_spec('')
                          }
                      }
                  }
              }
              definition {
                  cps {
                      sandbox(true)
                      script("testPipeline()")
                  }
              }
          }
          

          Let me try for the Bitbucket comment-393252

           

          Gnanasekaran Gajendiran added a comment - - edited daspilker Thanks. This works fine. pipelineJob ( "TestJob" ) { properties { pipelineTriggers { triggers { pollSCM { scmpoll_spec('') } } } } definition { cps { sandbox( true ) script( "testPipeline()" ) } } } Let me try for the Bitbucket comment-393252  

          Gnanasekaran Gajendiran added a comment - - edited

          daspilker, For bitbucket-push-and-pull-request-plugin  below one works

          pipelineJob ("TestJob") {
              triggers{
                  bitbucketTriggers {
                      pullRequestCreatedAction()
                  }
              }
              definition {
                  cps {
                      sandbox(true)
                      script("createBranchJobAll()")
                  }
              }
          }
          
          
          

          but not this one

          pipelineJob ("TestJob") {
              properties {
                  pipelineTriggers {
                      triggers {
                          bitbucketTrigger {
                              triggers {
                                  bitBucketPPRPullRequestServerTriggerFilter {
                                      actionFilter {
                                          bitBucketPPRPullRequestServerMergedActionFilter{
                                              allowedBranches('master')
                                              isToApprove(false)
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
              definition {
                  cps {
                      sandbox(true)
                      script("cicdPipeline()")
                  }
              }
          }

          reference syntax

           

          Plugin required: bitbucket-push-and-pull-request-plugin 

          Gnanasekaran Gajendiran added a comment - - edited daspilker , For bitbucket-push-and-pull-request-plugin   below one works pipelineJob ( "TestJob" ) { triggers{ bitbucketTriggers { pullRequestCreatedAction() } } definition { cps { sandbox( true ) script( "createBranchJobAll()" ) } } } but not this one pipelineJob ( "TestJob" ) { properties { pipelineTriggers { triggers { bitbucketTrigger { triggers { bitBucketPPRPullRequestServerTriggerFilter { actionFilter { bitBucketPPRPullRequestServerMergedActionFilter{ allowedBranches( 'master' ) isToApprove( false ) } } } } } } } } definition { cps { sandbox( true ) script( "cicdPipeline()" ) } } } reference syntax   Plugin required:  bitbucket-push-and-pull-request-plugin  

          We are also experiencing the same issue with `cron(...)`. Our workaround is to use the deprecated way.

           

          Jean-Martin Archer added a comment - We are also experiencing the same issue with `cron(...)`. Our workaround is to use the deprecated way.  

          Lukas Bednar added a comment - - edited

          We are experiencing the same for gitlab, gerrit trigger and URL Trigger.

           

          pipelineJob ("TestJob") {
              properties {
                  pipelineTriggers {
                      triggers {
                          gitlab {
                              triggerOnMergeRequest(true)
                              triggerOnPush(false)
                          }
                      }
                  }
              }
          }
          
          pipelineJob ("TestJob") {
              properties {
                  pipelineTriggers {
                      triggers {
                          gerrit {
                              triggerOnEvents {
                                  patchsetCreated()
                                  draftPublished()
                                  changeRestored()
                              }
                              gerritProjects {
                                  gerritProject {
                                      pattern('my-project')
                                      branches {
                                          branch {
                                              compareType('reg_exp')
                                              pattern('.*')
                                          }
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
          }
          

           

           

          Lukas Bednar added a comment - - edited We are experiencing the same for gitlab, gerrit trigger and URL Trigger.   pipelineJob ( "TestJob" ) { properties { pipelineTriggers { triggers { gitlab { triggerOnMergeRequest( true ) triggerOnPush( false ) } } } } } pipelineJob ( "TestJob" ) { properties { pipelineTriggers { triggers { gerrit { triggerOnEvents { patchsetCreated() draftPublished() changeRestored() } gerritProjects { gerritProject { pattern( 'my-project' ) branches { branch { compareType( 'reg_exp' ) pattern( '.*' ) } } } } } } } } }    

          robbin added a comment -

          Hi,
          I'm also migrating to the new syntax but I can figure out why I keep getting this error:

          javaposse.jobdsl.dsl.DslScriptException: (script, line 3) No signature of method: javaposse.jobdsl.dsl.helpers.properties.PropertiesContext.pipelineTriggers() is applicable for argument types: (script$_run_closure1$_closure2$_closure4) values: [script$_run_closure1$_closure2$_closure4@16f6b021]

          pipelineJob ("TestJob") { 
          properties { 
                pipelineTriggers { 
                    triggers { 
                         pollSCM { 
                             scmpoll_spec('') 
                         } 
                    } 
               } 
          } 
          definition { cps { sandbox(true) script("testPipeline()") } } }
          
          

          ggnanasekaran77 I used your example.
          I'm using job_dsl V1.77.

          Any idea? thx in advance!

          robbin added a comment - Hi, I'm also migrating to the new syntax but I can figure out why I keep getting this error: javaposse.jobdsl.dsl.DslScriptException: (script, line 3) No signature of method: javaposse.jobdsl.dsl.helpers.properties.PropertiesContext.pipelineTriggers() is applicable for argument types: (script$_run_closure1$_closure2$_closure4) values:  [script$_run_closure1$_closure2$_closure4@16f6b021] pipelineJob ( "TestJob" ) { properties { pipelineTriggers { triggers { pollSCM { scmpoll_spec('') } } } } definition { cps { sandbox( true ) script( "testPipeline()" ) } } } ggnanasekaran77  I used your example. I'm using job_dsl V1.77. Any idea? thx in advance!

          Parvesh Mourya added a comment - - edited

          robbinvandamme: check the API for your jenkins installation and see if you are able to find this method under 'freeStyleJob' -> 'triggers' -> 'pollSCM' . 

          The complete API reference is available in your Jenkins installation at https://your.jenkins.installation/plugin/job-dsl/api-viewer/index.html.

          Parvesh Mourya added a comment - - edited robbinvandamme : check the API for your jenkins installation and see if you are able to find this method under 'freeStyleJob' -> 'triggers' -> 'pollSCM' .  The complete API reference is available in your Jenkins installation at https://your.jenkins.installation/plugin/job-dsl/api-viewer/index.html .

            jamietanna Jamie Tanna
            webminster Alan Sparks
            Votes:
            6 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: