我是 Jenkins 新手,我想使用 powershell 脚本获取 Jenkins 过去 15 天的所有作业的详细信息。我将通过邮件将 Jenkin 作业的详细信息发送给我的经理。
我已经尝试了下面的脚本,如果有人能解决我的问题,我将非常感激。
Hour=24;
Minute=60;
Second=60;
oneDayInSecond=hour*minute*second;
sevenDayInSecond=hour*minute*second*7;
now=Calendar.instance;
List=[];
Println("${now.time}");
checkNewProjects(Hudson.instance.items)
def checkNewProjects(items) {
For (items in items) {
last_build = items.lastbuild //or item.getlastbuild()
If (last_build) {
build_time = last_build.timestamp
If (now.time.time/1000-build_time.time.time/1000<sevenDayInSecond) {
item.save()
Println(item.name)
Println("\t\tlast build was built in less than 7 days");
Println("\t\tlast built was at ${build_time.time);
list<< item;
}
}
}
}