2016-05-11 35 views

回答

0

將Stash通告程序添加爲Jenkins構建作業配置中的後續步驟。

在你詹金斯作業配置去生成後操作部分,單擊添加生成後的行動和選擇通知藏匿實例 輸入藏匿基地URL,e. g. http://localhost:7990 or http://my.company/stash.

如有疑問,請向當地的存儲服務器並檢查瀏覽器中的URL。網址http://[email protected]:7991/projects e。 G。揭示服務器基址的URL,在這種情況下爲http://localhost:7991。 使用Credentials插件選擇存儲的憑證。

+1

正如我在我的問題:「配置頁面沒有」後生成動作「部分。」你的Jenkins 2多分支管道是否有這樣的部分? –

+0

這隻有在你使用標準jenkins工作時纔有效......問題是如何使用管道工具,我認爲你必須能夠將插件作爲一個步驟來調用。 – kenyee

1

我認爲它仍然與管道或多分支管道作業類型不兼容。

我認爲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''' 
} 

請注意,這是一個很簡單的例子,而不是複雜的插件。

+0

無法讓插件工作,因爲credentialsID無法使用最新的Jenkins 2.x ...他們不再使用UUID。這是最簡單的事情... – kenyee

+0

還要注意,URL必須採用以下格式:https:// /rest/build-status/1.0/commits/ kenyee

4

隱藏通告現在支持版本1.11以上的管道。

examples in the README

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步驟會將構建結果設置爲在非零退出代碼上失敗。如果您需要自定義成功/失敗邏輯,這應該是必要的。

相關問題