Pipeline: BUILD_URL for Blue Ocean

4,473 views
Skip to first unread message

Sverre Moe

unread,
Apr 18, 2018, 7:29:34 AM4/18/18
to Jenkins Users
We have the following content to mail notifications.
def content "Check console output at ${env.BUILD_URL} to view the results."

Where env.BUILD_URL has the following URL

Is there an environment variable to get Blue Ocean build URL?


A workaround would be to replace string values:
Multibranch Pipeline
def buildURL = env.BUILD_URL
def newBuildURL = buildURL.replace("job/${env.JOB_NAME}", "blue/organizations/jenkins/${env.JOB_NAME}")
newBuildURL
= newBuildURL.replace("job/${env.BRANCH_NAME}", "detail/${env.BRANCH_NAME}")

Pipeline
def buildURL = env.BUILD_URL
def newBuildURL = buildURL.replace("job/${env.JOB_NAME}", "blue/organizations/jenkins/${env.JOB_NAME}/detail/${env.JOB_NAME}")

Daniel Beck

unread,
Apr 19, 2018, 9:00:18 AM4/19/18
to jenkins...@googlegroups.com
Append /display/redirect to the URL.
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c7b463cd-f118-486d-9dfd-e2fad833712e%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Craig Rodrigues

unread,
Apr 20, 2018, 6:33:37 PM4/20/18
to Jenkins Users
Try:

env.RUN_DISPLAY_URL



If you look at this plugin: https://plugins.jenkins.io/display-url-api

you will see there these variables you can try:

RUN_DISPLAY_URL – links to the run result
RUN_CHANGES_DISPLAY_URL – links to the changes page for a run
JOB_DISPLAY_URL – links to the jobs homepage

--
Craig


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscribe@googlegroups.com.

Mark Gargan

unread,
Jul 11, 2018, 1:45:00 PM7/11/18
to Jenkins Users
Hi including ${RUN_DISPLAY_URL} only returns the classic job view url for me? 


Blue Ocean 1.3.5



emailext(
subject: "My Automation Test",
body: """<h3>Job has been flagged as ${currentBuild.result}!</h3>
<p>Click <a href="${BUILD_URL}Jenkins">here</a> for the Jenkins Classic Report</p>
<p>Click <a href="${RUN_DISPLAY_URL}Jenkins">here</a> for the Jenkins Blue Ocean</p>
""",
to: "${successfulRecipientListDefault}"
)
Craig


To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Reinhold Füreder

unread,
Jul 12, 2018, 2:56:02 AM7/12/18
to jenkins...@googlegroups.com

Hi Mark,

 

I am using something like this in a groovy HTML template (for emailext):

def blueOceanDisplayUrlProvider = org.jenkinsci.plugins.displayurlapi.DisplayURLProvider.all().find { it.displayName == "Blue Ocean" }

String blueOceanPipelineUrl = blueOceanDisplayUrlProvider.getJobURL(project)

 

In case you are OK with globally changing default URL provider to Blue Ocean, then this might help you: https://issues.jenkins-ci.org/browse/JENKINS-41578

 

HTH Reinhold

Mark Gargan

unread,
Jul 15, 2018, 4:29:45 PM7/15/18
to Jenkins Users
Hi Reinhold,

                 Thanks for taking the time to get back to me! Much appreciated!

I popped  in env.project instead of just project and alas it throws a nullpointer. have i got the correct project variable?

java.lang.NullPointerException
	at io.jenkins.blueocean.rest.factory.organization.OrganizationFactory.getContainingOrg(OrganizationFactory.java:88)
	at org.jenkinsci.plugins.blueoceandisplayurl.BlueOceanDisplayURLImpl.getJobURL(BlueOceanDisplayURLImpl.java:91)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Thanks,
Mark.

Reinhold Füreder

unread,
Jul 16, 2018, 4:15:55 AM7/16/18
to jenkins...@googlegroups.com

Hi Mark,

 

Your suspicion sounds good to me: the “project” variable you are using must be wrong?

 

The source code for your NPE: https://github.com/jenkinsci/blueocean-plugin/blob/15e7e594f79930465582df7894f22d333a6966c1/blueocean-rest/src/main/java/io/jenkins/blueocean/rest/factory/organization/OrganizationFactory.java#L88

 

Not sure if this helps you right away, but the binding of “project” variable in email-ext plugin is seemingly defined like this: https://github.com/jenkinsci/email-ext-plugin/blob/9012fcd1b9b2040f2d34c2723198a751eb81cce5/src/main/java/hudson/plugins/emailext/plugins/content/ScriptContent.java#L125

 

I have found this old personal comment when getting started with groovy templates and email-ext plugin:

Reply all
Reply to author
Forward
0 new messages