Trigger from pipeline model definition plugin

386 views
Skip to first unread message

Tim Downey

unread,
Nov 17, 2016, 9:17:05 AM11/17/16
to Jenkins Users
Hi all,

I'm using the pipeline model definition plugin (which is great btw!) to specify my pipelines.  I have a question about trigger though.  I'd like to use a poll based trigger instead of cron, but it's not clear on if it is supported.  Can anyone provide any feedback?

Here's the example from the wiki:

pipeline {
    agent any

    triggers
{
        cron
'@daily'
   
}

   
...
}

Instead of cron, I want to poll.  Unless I misunderstand, cron will definitely cause a build daily in the above configuration.  Instead, I'd like to configure Jenkins polling once a day instead.  This is necessary in my situation because push based triggers from my SCM don't actually trigger anything unless the Jenkins job is already set up to poll.  Specifically, I'm talking about what is the 'Poll SCM' build trigger from the gui panel.

I went ahead and tried poll as a trigger, but as you can see, that is not supported.  Supported methods within a triggers closure appear to be:

[Pipeline] End of Pipeline
java.lang.NoSuchMethodError: No such DSL method 'poll' found among steps [VersionNumber, archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, dockerLabel, echo, envVarsForTool, error, fileExists, getContext, git, input, isUnix, libraryResource, load, mail, milestone, node, parallel, properties, pwd, readFile, readTrusted, retry, script, sh, sleep, sshagent, stage, stash, step, svn, timeout, tool, unarchive, unstash, waitUntil, withContext, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, withMaven, wrap, writeFile, ws] or symbols [all, always, any, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, buildButton, buildDiscarder, caseInsensitive, caseSensitive, choice, choiceParam, clock, cloud, command, configFile, configFileProvider, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, downloadSettings, downstream, dumb, envVars, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, git, hyperlink, hyperlinkToModels, installSource, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobDsl, jobName, junit, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, myView, nodeProperties, nonStoredPasswordParam, none, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, run, runParam, schedule, scm, scmRetryCount, search, security, shell, slave, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, viewsTabBar, weather, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]

Daniel Beck

unread,
Nov 17, 2016, 9:47:07 AM11/17/16
to jenkins...@googlegroups.com

> On 17.11.2016, at 15:17, Tim Downey <timothy...@gmail.com> wrote:
>
> I went ahead and tried poll as a trigger, but as you can see, that is not supported. Supported methods within a triggers closure appear to be:
>

Should be 'pollSCM' (or 'pollScm'?). Note that the 'cron' trigger which you know works is also not listed.

Tim Downey

unread,
Nov 17, 2016, 10:12:55 AM11/17/16
to Jenkins Users, m...@beckweb.net
Hi Daniel.  Thanks for the suggestion.  I tried pollSCM and pollScm.  Both are unsupported.  The 'cron' trigger is in the list.  Highlighted below.

java.lang.NoSuchMethodError: No such DSL method 'pollScm' found among steps [VersionNumber, archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, dockerLabel, echo, envVarsForTool, error, fileExists, getContext, git, input, isUnix, libraryResource, load, mail, milestone, node, parallel, properties, pwd, readFile, readTrusted, retry, script, sh, sleep, sshagent, stage, stash, step, svn, timeout, tool, unarchive, unstash, waitUntil, withContext, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, withMaven, wrap, writeFile, ws] or symbols [all, always, any, apiToken, architecture, archiveArtifacts, artifactManager, batchFile, booleanParam, buildButton, buildDiscarder, caseInsensitive, caseSensitive, choice, choiceParam, clock, cloud, command, configFile, configFileProvider, cron, crumb, defaultView, demand, disableConcurrentBuilds, docker, downloadSettings, downstream, dumb, envVars, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, freeStyleJob, git, hyperlink, hyperlinkToModels, installSource, jdk, jdkInstaller, jgit, jgitapache, jnlp, jobDsl, jobName, junit, label, lastDuration, lastFailure, lastGrantedAuthorities, lastStable, lastSuccess, legacy, list, local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, myView, nodeProperties, nonStoredPasswordParam, none, overrideIndexTriggers, paneStatus, parameters, password, pattern, pipeline-model, pipelineTriggers, plainText, plugin, projectNamingStrategy, proxy, queueItemAuthenticator, quietPeriod, run, runParam, schedule, scm, scmRetryCount, search, security, shell, slave, stackTrace, standard, status, string, stringParam, swapSpace, text, textParam, tmpSpace, toolLocation, unsecured, upstream, viewsTabBar, weather, zfs, zip] or globals [currentBuild, docker, env, params, pipeline, scm]

Andrew Bayer

unread,
Nov 21, 2016, 2:24:42 PM11/21/16
to jenkins...@googlegroups.com, Daniel Beck
So the symbol on SCMTrigger was originally "scm", which turned out not to work in Pipeline due to overlapping with the auto-generated "scm" global variable. I changed the symbol to "pollScm" as of core Jenkins 2.22, but that means it won't work in Declarative on earlier core versions. In scripted Pipeline, you can use the old $class approach to defining an SCMTrigger (i.e., [$class: 'SCMTrigger', scmpoll_spec: '@daily', ignorePostCommitHooks: true]), but we don't currently allow the $class approach to be used for specifying triggers, parameters, job properties or wrappers in Declarative. 

A.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e04fbcc4-3c12-4ad3-823a-02c2e4e7a5f9%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tim Downey

unread,
Nov 22, 2016, 10:09:58 AM11/22/16
to jenkins...@googlegroups.com
Thanks Andrew.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/1j57KpAPzbY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPbPdOY%3DVk9ffOH9vE2jDEPsC%3DLFj0EA4J01XsZ-Uqyb9vqs1w%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages