![](/img/trans.png)
[英]Stash notifier plugin for jenkins generates the wrong jenkins URL
[英]Use stash notifier plugin on Jenkins 2.0 multibranch pipeline
我不知道如何在multibranch管道上設置stash通知程序插件。 配置頁面沒有“構建后操作”部分。
Stash Notifier現在支持版本1.11的管道。
node {
step([$class: 'StashNotifier']) // Notifies the Stash Instance of an INPROGRESS build
try {
// Do stuff
currentBuild.result = 'SUCCESS' // Set result of currentBuild !Important!
} catch(err) {
currentBuild.result = 'FAILED' // Set result of currentBuild !Important!
}
step([$class: 'StashNotifier']) // Notifies the Stash Instance of the build result
}
雖然它說設置currentBuild.result是“!重要!”,但我的經驗是,只有你的步驟還沒有這樣做才會出現這種情況。 例如,如果你有sh "false"
,你不需要在try / catch中包裝它,因為sh
步驟將在非零退出代碼上將構建結果設置為失敗。 只有在需要自定義成功/失敗邏輯時才需要這樣做。
我認為它仍然與管道或multibranch管道作業類型不兼容。
我認為Abhijeet Kamble意味着您可以使用http客戶端或curl自行發送更新。
像這樣的東西:
withCredentials([[$class : 'UsernamePasswordMultiBinding', credentialsId: "$env.componentCredentialsId",
usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
writeFile file: 'build.json', text: "{\"state\": \"SUCCESSFUL\", \"key\": \"${env.JOB_NAME}\", \"name\": \"${env.BUILD_TAG}\", \"url\": \"${env.BUILD_URL}\"}"
sh '''curl -u $USERNAME:$PASSWORD -H "Content-Type: application/json" -X POST $URL -d @build.json'''
}
請注意,這是一個非常簡單的示例,不像插件那么復雜。
使用Stash Notifier將其添加為Jenkins構建作業配置中的Post Step。
在Jenkins作業配置中,轉到Post-build Actions部分,單擊Add post-build action並選擇Notify Stash Instance輸入Stash base URL, eg http://localhost:7990 or http://my.company/stash.
如果有疑問,請轉到您當地的Stash服務器並在瀏覽器中檢查URL。 URL http://georg@localhost:7991/projects
例如顯示服務器基本URL,在這種情況下為http://localhost:7991
。 使用憑據插件選擇存儲憑據。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.