Swaroop Joseph
Swaroop Joseph

Reputation: 61

How to get the Build url of the triggered job in jenkins pipeline?

                script {
                     def job = build job: '<job>'
                           if (job.getResult().equals('FAILURE')) {
                           def jobName = '<job>'
                           def date = new Date().format('dd/MM/yyyy')
                                        echo "Build Result: " + job.getResult()
                                        slackSend color: "danger", message: "${jobName} failed on " + date + "\n Build URL - ${absoluteUrl}"
                                    }
                                    else {
                                        echo "Build Result: " + job.getResult()
                                    }
                        } 
          

How to get the build url for ''. By using 'JOB_URL' I get the url of the Parent Job. And 'absoluteUrl' throws ' No such property: absoluteUrl for class: groovy.lang.Binding' error.

Thanks for the help.

Upvotes: 0

Views: 3216

Answers (1)

Melkjot
Melkjot

Reputation: 518

absoluteUrl is not defined. job.getAbsoluteUrl() would give you the URL. See documentation

Upvotes: 3

Related Questions