Jenkins JobDSL种子作业由于缺少松弛的baseUrl而突然失败
我使用docker在Ubuntu 16.04上运行Jenkins 2.155 我有大约20个Jenkins JobDSL种子工作,这几年来一直没有问题 大约三天前,这些都失败了。我最终将问题缩小到缺少SlackJenkins JobDSL种子作业由于缺少松弛的baseUrl而突然失败,jenkins,jenkins-job-dsl,Jenkins,Jenkins Job Dsl,我使用docker在Ubuntu 16.04上运行Jenkins 2.155 我有大约20个Jenkins JobDSL种子工作,这几年来一直没有问题 大约三天前,这些都失败了。我最终将问题缩小到缺少SlackbaseUrl参数 起初,失败的输出是不同的,但后来我们尝试更新Jenkins以及所有插件,因为这是由于无论如何,错误改变了。但在任何情况下,我们都没有在初始错误之前进行任何更改 这是DSL脚本中的一个代码示例,尽管有许多类似的代码已经开始失败 /** * Job Con
baseUrl
参数
起初,失败的输出是不同的,但后来我们尝试更新Jenkins以及所有插件,因为这是由于无论如何,错误改变了。但在任何情况下,我们都没有在初始错误之前进行任何更改
这是DSL脚本中的一个代码示例,尽管有许多类似的代码已经开始失败
/**
* Job Config
* Each job should provide
* id - unique id of the job
* serverName - The Jenkins name of the server which needs to be connected snapshotted
**/
def webservers = [
[id: 'server1-automated-snapshot', serverName: 'Server 1'],
[id: 'server2-automated-snapshot', serverName: 'Server 2'],
[id: 'server3', serverName: 'Server 3'],
[id: 'server 4', serverName: 'Server 4'],
]
/**
* Job Template
* The job template for automated snapshot jobs. Changing this will update all the snapshot jobs.
*/
for(webserver in webservers) {
def jobName = webserver.id
jobDisplayName = webserver.serverName+' automated volume snapshot'
def jobDescription = """This job automatically runs the automated snapshot script located on the $webserver.serverName once a day."""
job(jobName) {
description(jobDescription)
displayName(jobDisplayName)
logRotator {
numToKeep(5)
}
configure {
it / 'properties' << 'hudson.plugins.disk__usage.DiskUsageProperty' {}
}
wrappers {
timestamps()
}
triggers {
cron('H 2 * * 1')
}
steps {
publishOverSsh {
server(webserver.serverName) {
transferSet {
execCommand('sudo /usr/local/sbin/snapshot.sh')
}
}
}
}
publishers {
mailer('techadmin@ibboost.com', true, false)
retryBuild {
rerunIfUnstable()
retryLimit(1)
fixedDelay(600)
}
slackNotifier {
room('#channel')
notifyAborted(true)
notifyFailure(true)
notifyNotBuilt(false)
notifyBackToNormal(true)
notifySuccess(false)
notifyRepeatedFailure(false)
notifyUnstable(true)
startNotification(false)
includeTestSummary(false)
includeCustomMessage(false)
customMessage(null)
sendAs(null)
commitInfoChoice('NONE')
teamDomain(null)
authToken(null)
}
wsCleanup {
cleanWhenAborted(true)
cleanWhenNotBuilt(true)
cleanWhenFailure(true)
cleanWhenSuccess(true)
cleanWhenUnstable(true)
}
}
}
}
然后在更新Jenkins和插件后,更改为:
[EnvInject] - Loading node environment variables.
Building on master in workspace /var/jenkins_home/workspace/seed-job
Cloning the remote Git repository
Cloning repository https://github.com/myrepo/jenkins-config
> git init /var/jenkins_home/workspace/seed-job # timeout=10
Fetching upstream changes from https://github.com/myrepo/jenkins-config
> git --version # timeout=10
using GIT_ASKPASS to set credentials Github
> git fetch --tags --progress https://github.com/myrepo/jenkins-config +refs/heads/*:refs/remotes/origin/*
> git config remote.origin.url https://github.com/myrepo/jenkins-config # timeout=10
> git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
> git config remote.origin.url https://github.com/myrepo/jenkins-config # timeout=10
Fetching upstream changes from https://github.com/myrepo/jenkins-config
using GIT_ASKPASS to set credentials Github
> git fetch --tags --progress https://github.com/myrepo/jenkins-config +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision asdasdf3c68966e2078afcgth6579cf485 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f asdasdf3c68966e2078afcgth6579cf485
Commit message: "Appending seperator to workspace path to fix groovy.util.ResourceException"
> git rev-list --no-walk asdasdf3c68966e2078afcgth6579cf485 # timeout=10
Processing DSL script jobBuilder.groovy
ERROR: (jobBuilder.groovy, line 67) the following options are required and must be specified: baseUrl
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE
因此,从逻辑上讲,这表明我们需要将baseUrl添加到DSL脚本中。但有人知道为什么吗?还有,有人知道为什么我们没有改变任何事情,情况却突然改变了吗
编辑
我已经在脚本中添加了以下参数(在slackNotifier
下),这解决了这个问题;但它仍然没有回答这个问题
baseUrl(null)
这是Jenkins插件“Slack Notifier”v2.2中引入的一个新参数
Slack插件v2.4中的这一提交破坏了与作业DSL脚本的兼容性,使许多选项成为强制性的(再次): 兼容性已在v2.11中恢复:
谢谢你,尽管在这之前我已经上过2.3了。问题是,它似乎在以前没有的地方变成了必需的,而这在插件没有升级的情况下就发生了。值得注意的是,将
baseUrl(null)
选项保留在中会导致作业失败,这需要删除,正如我今天早上发现的那样。
baseUrl(null)