简体   繁体   中英

Jenkins DSL Plugin (>=1.77): Use gerrit-trigger in pipelineJob

I don't know how to use the gerrit-trigger plugin in a DSL pipelineJob. According to the dsl plugin doc triggers is deprecated for pipelineJobs. And from the wiki 1.77 replaced by pipelineTriggers. So I have change my triggers section to

properties {
    pipelineTriggers {
        triggers {
            gerrit {
                events {
                    patchsetCreated()
                }
                project('**My/Git/Repo', '**')
            }
        }
    }
}

However, when I use pipelineTriggers i get the following

ERROR: (configure_seed_jobs.groovy, line 25) No signature of method: events() is applicable for argument types: (configure_seed_jobs$_run_closure1$_closure4$_closure9$_closure10$_closure11$_closure12) values: [configure_seed_jobs$_run_closure1$_closure4$_closure9$_closure10$_closure11$_closure12@3bcd6c54] Possible solutions: gerritProjects(), buildFailureMessage(), buildNotBuiltMessage(), buildStartMessage(), buildSuccessfulMessage(), buildUnstableMessage(), buildUnsuccessfulFilepath(), changeSubjectParameterMode(), commentTextParameterMode(), commitMessageParameterMode(), customUrl(), dependencyJobsNames(), dynamicTriggerConfiguration(), escapeQuotes(), gerritBuildFailedCodeReviewValue(), gerritBuildFailedVerifiedValue(), gerritBuildNotBuiltCodeReviewValue(), gerritBuildNotBuiltVerifiedValue(), gerritBuildStartedCodeReviewValue(), gerritBuildStartedVerifiedValue(), gerritBuildSuccessfulCodeReviewValue(), gerritBuildSuccessfulVerifiedValue(), gerritBuildUnstableCodeReviewValue( ), gerritBuildUnstableVerifiedValue(), gerritSlaveId(), nameAndEmailParameterMode(), notificationLevel(), serverName(), silentMode(), silentStartMode(), skipVote(), triggerConfigURL(), triggerOnEvents()

What am I missing?

I had the same problem, because either events{..} or project() is no more available to gerrit in pipelineTriggers, you should use triggerOnEvents {..} and gettitProjects{...} instead. For more details, you could find them in the document on your jenkins (eg http://0.0.0.0:8080/plugin/job-dsl/api-viewer/ )

properties {
  pipelineTriggers {
    triggers {
      gerritTrigger {
        gerritProjects {
          gerritProject {
            compareType('PLAIN')
            pattern('**My/Git/Repo')
            branches {
              branch {
                compareType('PLAIN')
                pattern('master')
              }
            }
          }
        }
      triggerOnEvents {
        changeMerged()
      }
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM