jenkins - How to get the last build number from a Trigger/call builds on other projects if a multibranch pipeline Build is called? -


i use parameterized trigger plugin jenkins trigger multibranch pipeline project (red outlook addin). after build has finished want copy artifacts via copy artifact plugin. add build step "copy artifacts project" project name "red outlook addin/${cios_branch_name}" because branch name parameter. works if specify build number "12". if set build number $triggered_build_number_red_outlook_addin_${cios_branch_name} error: unable find project artifact copy.

how can call $triggered_build_number_ parameter specified branch?

thx chris

you query json api of jenkins server, example using httprequest plugin:

@noncps def parsejson(string text) {     def sup = new jsonslurper()     def json = sup.parsetext(text)     sup = null     return json }  def getlaststablebuildnumber(string project, string branchname = 'master') {     def response = httprequest url: "http://jenkins/job/${project}/job/${branchname}/laststablebuild/api/json", validresponsecodes: '200'     def json = parsejson(response.content)     return json.number } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -