Jenkins sending notifications to the wrong commit id

有些话、适合烂在心里 提交于 2019-12-08 03:58:27
Joey

Here is an example of Bitbucket Cloud:

First install HTTP Request plugin on Jenkins

Then use the following Pipeline Code:

void notifyBitbucket(state)
{
    def object_data = "{\"state\": \"${state}\",\"key\": \"${env.JOB_NAME} ${currentBuild.displayName}\",\"name\": \"${env.JOB_NAME} ${currentBuild.displayName}\",\"url\": \"https://jenkins/job/${env.JOB_NAME}/${currentBuild.number}/\",\"description\": \"\"}"
    def response = httpRequest authentication: '<credential ID>', acceptType: 'APPLICATION_JSON', contentType: 'APPLICATION_JSON', httpMode: 'POST', requestBody: object_data, url: "https://api.bitbucket.org/2.0/repositories/<user name>/<repo>/commit/<commit id>/statuses/build"
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!