每当CI使用groovy脚本失败时,我都会尝试发布到松弛频道。但是,当我尝试在内部故障块中实现此操作时,却出现了此错误
Error when executing failure post condition:
java.lang.NoSuchMethodError: No such DSL method 'steps' found among steps [archive, bat, build, catchError, checkout, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, envVarsForTool, error, fileExists, getContext, git, input, isUnix, junit, library, libraryResource, load, lock, mail, milestone, node, parallel
但是,我能够应用相同的代码在stage块下的其他管道中发送松弛通知。应用于post block时似乎出现了问题。
post {
always {
cleanWs()
}
failure {
steps {
slackSend baseUrl: 'https://hooks.slack.com/services/',
channel: '#build-failures',
iconEmoji: '',
message: "CI failing for - #${env.BRANCH_NAME} - ${currentBuild.currentResult} (<${env.BUILD_URL}|Open>)",
teamDomain: 'differentau',
tokenCredentialId: 'slack-token-build-failures',
username: ''
}
}
}
在此方面的任何帮助将不胜感激。
答案 0 :(得分:0)
这应该有效:
post {
always {
cleanWs()
}
failure {
slackSend baseUrl: 'https://hooks.slack.com/services/',
channel: '#build-failures',
iconEmoji: '',
message: "CI failing for - #${env.BRANCH_NAME} - ${currentBuild.currentResult} (<${env.BUILD_URL}|Open>)",
teamDomain: 'differentau',
tokenCredentialId: 'slack-token-build-failures',
username: ''
}
}