我目前正在编写一个脚本,该脚本应归档去年使用过的所有作业,我找不到任何应该搁置这些作业的命令。 知道怎么做吗? 这是我的剧本:
import hudson.model.*
jobs = hudson.model.Hudson.instance.items
Date date = new Date ()
currentTimeInMillis = date.getTime();
println "Today is " + date + " In MilSec " + currentTimeInMillis
def milSecondInSecond = 1000
def secondsInMinute = 60
def monutesInHour = 60
def secondsInHour = secondsInMinute*monutesInHour
def hoursInDay = 24
def minutesInDay = monutesInHour * hoursInDay
def secondsInDay = minutesInDay*secondsInMinute
def daysInYear = 365.242199
def hoursInYear = daysInYear*hoursInDay
def minutesInYear = hoursInYear*monutesInHour
def secondsInYear = minutesInYear*secondsInMinute
def milSecondsInYear = secondsInYear*milSecondInSecond
println "The milSeconds in year is " + milSecondsInYear
for (job in jobs) {
lastbuild = job.getLastBuild()
if (lastbuild != null) {
lastbuildInMilSeconds = lastbuild.getTimeInMillis()
def dif = currentTimeInMillis - lastbuildInMilSeconds
if (dif > milSecondsInYear) {
println job.getDisplayName() + " " + lastbuild.getTimeInMillis()
}
}
}
任何想法我应该添加哪些命令,我知道有一个插件,但我想自动执行此过程。
答案 0 :(得分:0)
选项1:
安装Shelve Project Plugin并让您的Groovy代码调用ShelveProjectTask来执行实际的搁置工作
选项2:
阅读Shelve Project Plugin的代码并在脚本中重现。
选项1听起来更容易,更可靠。您仍然可以获得自动化的好处。再加上重用的好处。