Skip to content

Instantly share code, notes, and snippets.

@bryantrobbins
Last active August 29, 2015 13:57
Show Gist options
  • Save bryantrobbins/9872943 to your computer and use it in GitHub Desktop.
Save bryantrobbins/9872943 to your computer and use it in GitHub Desktop.
Example of using JenkinsClient from bryantrobbins/jenkinsutils
// Get credentials and URL for Jenkins server from args
// This constructor builds URL of "http://host:port/path", e.g., localhost, 8080, "" for default install
jenkinsClient = new JenkinsClient(jenkinsHost, jenkinsPort, jenkinsPath, jenkinsUser, jenkinsPass)
// Also Process input arguments (args) to get any global params for Jenkins job
for(int i=0; i<batchSize; i++){
// update/obtain job-specific params
// build Map of params
// I have only used text params, but perhaps others supported via Jenkins Remote API
def jobParams = new HashMap<String, String>();
jobParams.put("PARAM_A", param_a)
jobParams.put("PARAM_B", param_b)
jobParams.put("PARAM_C", param_c)
jobParams.put("PARAM_D", param_d)
jobParams.put("PARAM_E", param_e)
// Use Jenkins client to launch job
jenkinsClient.submitJob("MySingleJob", jobParams)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment