我可以在 Jenkins 中安排一次性 运行 的构建吗?没有cron的任何解决方案
Can I schedule a build for onetime run in Jenkins ? Any solution without cron
我不需要 cron 作业,因为在生产中 运行 只需要构建一次而不是 periodically.Is 有一种方法可以在没有 cron 的情况下在预定时间构建管道。
一种方法是 - 您可以远程触发它
https://www.jenkins.io/doc/book/using/remote-access-api/
假设您有一个 Linux 盒子,您可以使用“at”命令安排它
at 9:30 PM Fri
curl -X POST JENKINS_URL/job/JOB_NAME/build \
--data token=TOKEN \
--data-urlencode json='{"parameter": [{"name":"id", "value":"123"},\
{"name":"verbosity", "value":"high"}]}'
job 2 at Fri Jan 29 21:30:00 2016
然后用
看看
at -c 2
您可以通过脚本控制台或作业使用 Groovy 安排构建:scheduleBuild2
:
def waittime = 100 // in secs
def jobName = 'folder/jobname' //aka it.fullName
Jenkins.instance.getItemByFullName(jobName).scheduleBuild2(waittime)
quietPeriod - 开始前等待的秒数(通常为 0)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod, Action... actions)
Description copied from interface:
ParameterizedJobMixIn.ParameterizedJob Provides a standard
implementation of SCMTriggerItem.scheduleBuild2(int,
hudson.model.Action...) to schedule a build with the ability to wait
for its result. That job method is often used during functional tests
(JenkinsRule.assertBuildStatusSuccess).
Specified by: scheduleBuild2 in interface
ParameterizedJobMixIn.ParameterizedJob<P extends
AbstractProject<P,R>,R extends AbstractBuild<P,R>> Parameters:
quietPeriod - seconds to wait before starting (normally 0) actions -
various actions to associate with the scheduling, such as
ParametersAction or CauseAction Returns: a handle by which you may
wait for the build to complete (or just start); or null if the build
was not actually scheduled for some reason
我不需要 cron 作业,因为在生产中 运行 只需要构建一次而不是 periodically.Is 有一种方法可以在没有 cron 的情况下在预定时间构建管道。
一种方法是 - 您可以远程触发它 https://www.jenkins.io/doc/book/using/remote-access-api/
假设您有一个 Linux 盒子,您可以使用“at”命令安排它
at 9:30 PM Fri
curl -X POST JENKINS_URL/job/JOB_NAME/build \
--data token=TOKEN \
--data-urlencode json='{"parameter": [{"name":"id", "value":"123"},\
{"name":"verbosity", "value":"high"}]}'
job 2 at Fri Jan 29 21:30:00 2016
然后用
看看at -c 2
您可以通过脚本控制台或作业使用 Groovy 安排构建:scheduleBuild2
:
def waittime = 100 // in secs
def jobName = 'folder/jobname' //aka it.fullName
Jenkins.instance.getItemByFullName(jobName).scheduleBuild2(waittime)
quietPeriod - 开始前等待的秒数(通常为 0)
public QueueTaskFuture<R> scheduleBuild2(int quietPeriod, Action... actions)
Description copied from interface: ParameterizedJobMixIn.ParameterizedJob Provides a standard implementation of SCMTriggerItem.scheduleBuild2(int, hudson.model.Action...) to schedule a build with the ability to wait for its result. That job method is often used during functional tests (JenkinsRule.assertBuildStatusSuccess).
Specified by: scheduleBuild2 in interface ParameterizedJobMixIn.ParameterizedJob<P extends AbstractProject<P,R>,R extends AbstractBuild<P,R>> Parameters: quietPeriod - seconds to wait before starting (normally 0) actions - various actions to associate with the scheduling, such as ParametersAction or CauseAction Returns: a handle by which you may wait for the build to complete (or just start); or null if the build was not actually scheduled for some reason