Bipin Tiwari
Bipin Tiwari

Reputation: 300

Send Git commit message to slack channel after successful build in Jenkins

I have setup Jenkins for CI/CD. I am able to make successful build using git. After build is successful I upload the artifact to dropbox and once that is complete I want to send message to slack channel with the link from dropbox and also the commit messages.

I am able to send link to slack after some tweaking but I am unable to send git commits as message after the success to slack channel.

Anyone have any idea. I am using pipeline job for sending link to slack channel.

Upvotes: 0

Views: 1282

Answers (1)

Dmitrii Kalashnikov
Dmitrii Kalashnikov

Reputation: 97

stage('Get commit details') {
    steps {
        script {
            env.GIT_COMMIT_MSG = sh (script: 'git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim()
            env.GIT_AUTHOR = sh (script: 'git log -1 --pretty=%cn ${GIT_COMMIT}', returnStdout: true).trim()
        }
    }
}

Upvotes: 1

Related Questions