我如何安排将来要执行的工作,但是只有一次 [英] How can I schedule a job to run in the future, but only one time ever

查看:57
本文介绍了我如何安排将来要执行的工作,但是只有一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想安排一个在将来的指定时间最多执行一次的作业(通常该时间将在当晚的晚上,几个小时后执行).我想用詹金斯做到这一点.如果詹金斯在这段时间内碰巧倒下了,这份工作就不会被解雇-很好.

I want to schedule a job that will execute at most once at a specified time in the future (usually that time would just be later that night, after hours). I want to use Jenkins to do this. If Jenkins happened to be down during that time, the job wouldn't fire - that's fine.

目前,我正计划在启用定期构建"的情况下进行一项新工作,并将时间表设置为"0 19 29 01 *".

At the moment, I'm planning to make a new job with "build periodically" enabled, and set the schedule to something like "0 19 29 01 *".

目的是安排作业在1月29日的19:00运行.

The intent being to schedule the job to run at 19:00 on the 29th of January.

缺点是,每次执行此操作时,我都必须记住要在明年之前的某个时间删除/禁用该作业,否则它将再次运行(那很不好).无论如何,我都会手动检查作业的结果,所以做起来并不难.我只是希望有人能够指出一种安排Jenkins运行一次性"作业的方法-这样我就不会因为忘记禁用该作业而搞砸了.

The downside being that every time I do this, I must remember to delete/disable the job sometime before next year, or it will run again (that would be bad). I'd be checking the results of the job manually anyway, so not too hard to do. I'm just hoping someone might be able to point out a way to schedule a "one off" job run with Jenkins - that way I can't mess things up by forgetting to disable the job.

推荐答案

安装计划构建插件".增加了在以后的某个时间点安排构建的功能.向用户询问日期和时间,并将构建添加到具有相应静默期的构建队列中."

Install the "Schedule Build Plugin". "Adds capability to schedule a build for a later point in time. Asks the user for a date and time and adds the build to the build queue with the respective quiet period."

安装插件后似乎仍需要重新启动jenkins,即使您看到计划构建的图标.

Restart jenkins seems to be needed after plugin install even though you see the icons for a scheduled build.

https://wiki.jenkins-ci.org/display/JENKINS/Schedule + Build + Plugin

注意:初次安装(使用jenkins 2.2)后,我收到一条警告插件提供了GET".确实确实有某种计划的工作,它说它在13小时内到期",这对我的计划时间是正确的.它没有运行这项工作.:-(

BEWARE: After initial install (with jenkins 2.2) I got a warning "plugin offered a GET". There did appear to be some sort of a job scheduled and it said it "expires in 13hr" which was correct for the time I scheduled. It did not run the job. :-(

看到的警告:

You must use POST method to trigger builds. (From scripts you may instead pass a per-project authentication token, or authenticate with your API token.) If you see this page, it may be because a plugin offered a GET link; file a bug report for that plugin.

网址,大概是GET:

http://jenkins:xxxx/job/jobname/build?delay=47212sec

这是与Jenkins 2.2和Schedule Build Plugin 0.3.4一起使用的

This was with Jenkins 2.2 and Schedule Build Plugin 0.3.4

我现在可以使用我的jenkins 2.7.4和从源代码构建的Schedule Build Plugin.

I have it working now for me jenkins 2.7.4 and Schedule Build Plugin built from source.

解决方案::使用最新的jenkins并等待新版本的插件(> 0.3.4)...(或从源代码构建).插件上已经存在一个关于GET问题的错误,并且已修复源代码,但最新版本中尚未修复.2016年9月26日: https://issues.jenkins-ci.org/browse/JENKINS-28961 可从源代码构建schedule_build.hpi.对于jenkins 2.2,如果在jenkins中禁用了CSRF保护,则可以正常工作.

Solution: Use latest jenkins and wait for new release of plugin (>0.3.4) . . . (or build from source). There is already a bug open on the plugin for the GET problem and a fix in source code but not yet in latest release. 26/Sep/2016: https://issues.jenkins-ci.org/browse/JENKINS-28961 Building schedule_build.hpi from source this plugin works. For jenkins 2.2 it worked IF CSRF Protection is disabled in jenkins.

这篇关于我如何安排将来要执行的工作,但是只有一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆