jenkins - Jenkins 管道 Cron Auto Scheduler 作业在调度程序/计时器运行后用 Jenkins UI 中的默认值覆盖用户输入的值
问题描述
我正在创建 Dataflow Jenkins 自动调度程序作业,用户可以在其中输入运行数据流作业所需的一些参数,并且应该能够安排作业。用户可以在需要时通过更改 Jenkins UI/控制台中的 cron 值来安排作业。
该作业按预期工作,它在指定时间安排作业,并获取用户在 Jenkins 控制台的输入文本字段中提供的任何值,并使用用户输入的值触发。但是在调度程序/计时器运行并完成作业后,后续作业运行,它会在调度程序/计时器运行后用 Jenkins UI 中的默认值覆盖用户输入的值。“Jenkins 管道 Cron 自动调度程序作业在调度程序/计时器运行后用 Jenkins UI 中的默认值覆盖用户输入的值”
有没有人遇到过类似的问题或对上述查询有解决方案?感谢您在这件事上的帮助。
这是我的 Jenkins groovy 脚本文件代码
//Dataflow Jenkins pipeline auto scheduler job
properties([
parameters([
choice(name: 'jarType', choices: ['snapshot','release'], description: 'Select the JarType to execute the files'),
string(name: 'hour', description: 'The hour of the day in 24 hour in (0-23) format', defaultValue: '14'),
string(name: 'dayInMonth', description: 'DOM: The day in the month in (1–31) format', defaultValue: '*'),
string(name: 'theMonth', description: 'MONTH: The month in (1–12) format', defaultValue: '*'),
string(name: 'dayInWeek', description: 'DOW: The day in the week in (0–7) format', defaultValue: '*'),
string(name: 'jobName', description: 'Please enter jobName for the Dataflow job', defaultValue: 'test'),
string(name: 'project', description: 'Please enter project for the Dataflow job', defaultValue: 'test'),
]),
pipelineTriggers(createPipelineTriggers())
])
//below is the scheduling part
def createPipelineTriggers() {
echo "H ${params.hour} ${params.dayInMonth} ${params.theMonth} ${params.dayInWeek} ${params.jobName} ${params.project}"
if (env.BRANCH_NAME == 'develop') {
// return [cron("H ${params.hour} ${params.dayInMonth} ${params.theMonth} ${params.dayInWeek} %jobName=${params.jobName}; project=${params.project}")]
return [cron("H ${params.hour} ${params.dayInMonth} ${params.theMonth} ${params.dayInWeek}")]
}
return []
}
node("test-pod") {
container('test-container') {
stage("Checkout Scm"){
checkout scm
}
stage("Download ${params.jarType} CI jar from Nexus") {
echo "${params.jarType}"
//****
}
stage("Download xxxx and xxxx from Nexus") {
//**
}
stage("Running dataflow job") {
rootDir = pwd()
try {
sh "java -jar ${params.application}.jar \\\n" + "--runner=DataflowRunner --jobName=${params.jobName} --project=${params.project}
} catch (Exception e) {
echo "dataflow job Failed"
}
}
}
}
解决方案
推荐阅读
- python - 如何将时间偏移应用于熊猫时间戳间隔?
- c# - 如何通过 C# 中的值选择特定的复选框项
- docker - 如何将 docker 镜像从 USS 复制到 IBM zCX 服务器
- javascript - 我可以使用 Javascript 中的自引用函数定义对象的属性吗?
- java - Java中超时的用户输入
- python-3.x - 在 Python 中执行每个子类函数之前调用父类函数
- android - 更换工具栏后汉堡图标未正确显示
- javascript - 如何使用 Hooks 在 React Component 中重新启动音频
- excel - 如果满足条件,将行从一个工作簿复制到另一个工作簿
- python - 在每行之后迭代两个列表切换方向的更多pythonic方式?