Search code examples
jenkinsslackjenkins-slack-plugins

Sending slack message in jenkins with ${currentBuild.number}


Hey i've been trying to send message with my number of build in a slack message in my jenkins pipeline using slacksend like this

 slackSend channel: 'developer-team', message: 'The unit tests have been successful for Build N°: ${currentBuild.number}'

but the message i get from slack is this way :

The unit tests have been successful for Build N°: ${currentBuild.number}

i don't know how to fix to get the appropriate message


Solution

  • Try like this:

    slackSend channel: '#notification', color: 'good', message: "The unit tests have been successful for Build N°: ${env.BUILD_NUMBER}", teamDomain: 'testnotifgroup', tokenCredentialId: 'slack-token'
    

    Use double quotes " " to wrap your message