Skip to content

Instantly share code, notes, and snippets.

View clifford-github's full-sized avatar

Clifford Sanders clifford-github

View GitHub Profile
@clifford-github
clifford-github / gist:7936030
Created December 12, 2013 21:41
access build parameter in Jenkins plugin
try {
EnvVars envVars;
envVars = build.getEnvironment(listener);
listener.getLogger().println("DEPLOY_ON-DEV: " + envVars.get("DEPLOY_ON_DEV"));
} catch (IOException e1) {
listener.getLogger().println(e1);
} catch (InterruptedException e1) {
listener.getLogger().println(e1);
}
@clifford-github
clifford-github / gist:7919842
Created December 11, 2013 22:41
get jobname from running build
String jobname = build.getParent().getDisplayName();
@clifford-github
clifford-github / gist:7890657
Created December 10, 2013 13:35
get complete absolute url to a build run
/**
* 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();
}
@clifford-github
clifford-github / gist:7749616
Created December 2, 2013 13:43
Display all Jobs in tabbed/nested view
jenkins.model.Jenkins.instance.getViews().each {
if (it.name.startsWith("Team")) {
println it.name
if (it instanceof hudson.plugins.nested_view.NestedView) {
it.getViews().each {
println "- " + it.name
it.getItems().each {
println "--- " + it.name
}
}
@clifford-github
clifford-github / gist:7748223
Last active July 31, 2024 09:16
Get list of Jobs in a View Groovy from within Jenkins. Run the following snippet in the Scripting console or a Groovy build step. The latter requires the installation of the Groovy plugin
hudson.model.Hudson.instance.getView('<VIEW>').items.each() {
println it.fullDisplayName
}