Skip to content

Instantly share code, notes, and snippets.

@t3knoid
Created February 20, 2018 20:23
Show Gist options
  • Save t3knoid/24688a0f8c3631d7e907fbc8626f7d50 to your computer and use it in GitHub Desktop.
Save t3knoid/24688a0f8c3631d7e907fbc8626f7d50 to your computer and use it in GitHub Desktop.
This is an example on how to parse arguments passed to a groovy script
// This is an example on how to parse arguments passed to a groovy script
import jenkins.model.*
if (args.length != 2 ) {
println "Error on arguments!"
}
def jobName = args[0] ?: 'a_job'
def viewName = args[1] ?: 'a_view'
println jobName + ' ' + viewName
def v = Jenkins.instance.getView(viewName)
def i = Jenkins.instance.getItemByFullName(jobName)
if (v && i) {
v.add(i)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment