Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Slack Send Pipeline step configured values from global config

I have downloaded & installed Slack Notification Plugin in jenkins and using slackSend in the pipeline, it was working before but now getting an error as below: After this i downloaded Global Slack Notifier plugin, but still the same error,is there any setup required? Please advice

[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

Code is as below:

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'
       }
    }
like image 462
Smi Avatar asked Oct 16 '22 13:10

Smi


1 Answers

Did you add the slack Jenkins token for integration? Go to this Jenkins CI url, search for your team domain, then add a new configuration. Copy the name of the token or the token itself. Then go to your Jenkins pipeline script and add to slackSend, the domain and the token credential ID or the token in plain text (not secured). Should look something like this:

slackSend channel: '#ci', color: 'good', message: "Destroy Applied ${env.JOB_NAME} - ${env.BUILD_NUMBER}", teamDomain: 'your_domain.slack.com', tokenCredentialId: 'your_id'

or if you want to use the token in plain text token:'your_token' instead of the tokenCredentialId

Hope this helps!

like image 75
Alexandru Patrascu Avatar answered Oct 26 '22 23:10

Alexandru Patrascu