Jenkins Slack integration

后端 未结 8 776
一整个雨季
一整个雨季 2021-02-07 01:30

I want to use the Slack plugin in Jenkins to ping notifications to a Slack channel.

Jenkins says success when I test the connection, but I don\'t receive any notificatio

8条回答
  •  感情败类
    2021-02-07 02:02

    If you want to receive notifications using Jenkins declarative pipelines, you can install the Slack plugin, and then use it in the pipeline in this way:

        stage('Clone sources') {
            steps {
                slackSend (channel: "#mychannel", color: '#FFFF00', message: "STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})")
                git credentialsId: 'git_credentials', poll: false, branch: 'develop', url: 'https://mysource.com/mysimplenodejsexample.git'
            }        
        }
    

    Result:

    You can customize your message of course. Full example at:

    https://pillsfromtheweb.blogspot.com/2020/05/send-notifications-to-slack-from.html

提交回复
热议问题