Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jenkins - Trigger hourly build from scripted Jenkinsfile

Is there a way to trigger a Jenkins job to run every hour using the Jenkinsfile scripted pipeline syntax?

I have seen examples using the declarative syntax, but none using the pipeline syntax.

Declarative Syntax Example

pipeline {
    agent any

    triggers {
        cron '@daily'
    }

   ...
}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could use this snippet for Scripted pipeline syntax:

properties(
    [
        ...  , // other properties that you have
        pipelineTriggers([cron('0 * * * *')]),
    ]
)

Reference for properties is here. You can search for "pipelineTriggers" string and find out that triggers for build can be for example artifactory or something else from this list (extracted 2019-03-23 from linked doc page):

$class: 'ArtifactoryTrigger'
$class: 'AssemblaBuildTrigger'
bitBucketTrigger
bitbucketPush
$class: 'BuildResultTrigger'
$class: 'CIBuildTrigger'
$class: 'CodingPushTrigger'
$class: 'CronFolderTrigger'
$class: 'DeployDbTrigger'
$class: 'DockerHubTrigger'
$class: 'DosTrigger'
$class: 'ElOyente'
$class: 'FanInReverseBuildTrigger'
$class: 'FeatureBranchAwareTrigger'
$class: 'FilesFoundTrigger'
$class: 'FogbugzStatePoller'
$class: 'FolderContentTrigger'
GenericTrigger
gerrit
$class: 'GhprbTrigger'
$class: 'GitBucketPushTrigger'
githubBranches
githubPullRequests
githubPush
gitee
$class: 'GogsTrigger'
issueCommentTrigger
$class: 'IvyTrigger'
$class: 'JiraChangelogTrigger'
$class: 'JiraCommentTrigger'
$class: 'KanboardQueryTrigger'
$class: 'MailCommandTrigger'
$class: 'MavenDependencyUpdateTrigger'
$class: 'NugetTrigger'
p4Trigger
$class: 'PeriodicFolderTrigger'
$class: 'PollMailboxTrigger'
$class: 'PullRequestBuildTrigger'
$class: 'QuayIoTrigger'
$class: 'RemoteBuildTrigger'
upstream
$class: 'RundeckTrigger'
<code>scm</code>
$class: 'SelfieTrigger'
$class: 'SpoonTrigger'
$class: 'SqsBuildTrigger'
$class: 'TeamPRPushTrigger'
$class: 'TeamPushTrigger'
cron
$class: 'URLTrigger'
snapshotDependencies
$class: 'io.relution.jenkins.awssqs.SQSTrigger'
$class: 'io.relution.jenkins.scmsqs.SQSTrigger'
$class: 'org.cloudbees.literate.jenkins.promotions.PromotionTrigger'
$class: 'org.jenkinsci.plugins.deploy.weblogic.trigger.DeploymentTrigger'
$class: 'org.jenkinsci.plugins.deployment.DeploymentTrigger'

More info about scripted way here (sample from another question). Documentation that covers declarative pipeline is here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...