简体   繁体   中英

how to get build number of other job in jenkins pipeine

I have created a pipeline where for build there is one job and for mail notification another job. I need to get the build job latest BUILD_NUMBER(either success or failure whatever) in mail notification job and i should publish the build job latest url as a mail notification regarding the buildstatus. How could i achieve this?

I think there are multiple ways that you could achieve this. Let's call your 2 builds A (build) and B (mail notification).

  1. Call B from A; pass whatever information you need in B as a parameter
  2. You can use a combination of this script and the Job API .

For #2, I'm thinking you would have something like this in your B job:

def jobname = "<name of Job A>"
def job = Jenkins.instance.getItemByFullName(jobname)
def build = job.getLastBuild()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM