Created
December 10, 2013 13:35
-
-
Save clifford-github/7890657 to your computer and use it in GitHub Desktop.
get complete absolute url to a build run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* returns the complete url to a build run | |
* e.g. http://localhost:8080/job/test/5/ | |
* @param build | |
* @return build run url as String | |
*/ | |
private String getAbsoluteBuildUrl(AbstractBuild build) { | |
return getBaseUrl() + build.getUrl(); | |
} | |
/** | |
* returns the value that is configured in | |
* Manage Jenkins -> Configure System -> Jenkins URL | |
* e.g. http://localhost:8080/ | |
* After new installation this value has to be changed once | |
* to have an effect. | |
* @return base url as String | |
*/ | |
private String getBaseUrl() { | |
final String rootUrl = Jenkins.getInstance().getRootUrl(); | |
if (StringUtils.isNotEmpty(rootUrl)) { | |
return rootUrl; | |
} | |
return Jenkins.getInstance().getRootUrlFromRequest(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment