我已经在jenkins中下载并安装了Slack Notification Plugin,并在管道中使用了slackSend,它之前可以正常工作,但是现在出现如下错误:在此之后,我下载了Global Slack Notifier插件,但仍然是相同的错误,是否有需要设置吗?请指教
[Pipeline] slackSend
run slackstepsend, step null:false, desc null:false
Slack Send Pipeline step configured values from global config - baseUrl: true, teamDomain: true, token: true, channel: false, color: false
ERROR: Slack notification failed. See Jenkins logs for details.
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: FAILURE
代码如下:
if (dstry) {
def status = sh(returnStatus: true, script: "set +e; terraform plan -destroy -var-file=my.tfvars -out=destroy.tfplan")
echo "Plan Status : ${status}"
def destroyExitCode = sh(returnStatus: true, script: "set +e; terraform destroy -auto-approve")
echo "Terraform Destroy Exit Code: ${destroyExitCode}"
if (destroyExitCode == "0") {
slackSend channel: '#ci', color: 'good', message: "Destroy Applied ${env.JOB_NAME} - ${env.BUILD_NUMBER} ()"
currentBuild.result = 'SUCCESSFUL'
} else {
slackSend channel: '#ci', color: 'danger', message: "Destroy Failed: ${env.JOB_NAME} - ${env.BUILD_NUMBER} ()"
currentBuild.result = 'FAILURE'
}
}
答案 0 :(得分:1)
您是否添加了松弛的Jenkins令牌以进行集成? 转到此Jenkins CI url,搜索您的团队域,然后添加新配置。复制令牌的名称或令牌本身。然后转到您的Jenkins管道脚本,并将域和令牌凭证ID或令牌以纯文本(不安全)添加到slackSend中。应该看起来像这样:
slackSend channel: '#ci', color: 'good', message: "Destroy Applied ${env.JOB_NAME} - ${env.BUILD_NUMBER}", teamDomain: 'your_domain.slack.com', tokenCredentialId: 'your_id'
或者如果您想使用纯文本token:'your_token'
而不是tokenCredentialId
希望这会有所帮助!