Jenkins Job Create From Template Version 1

Creates a new Jenkins job based on a provided template project on the same Jenkins server. To begin, an XML representation of the template project is retrieved. The template substitutions are then looped through and any text matching the substituion keys in the XML is replaced by the corresponding value in the template substitutions map (NOTE: Because the replacement is run over the whole config.xml file and not just the user input values, make sure to use strings that aren't likely to be used in the system generation of the Jenkins XML file). Any Jenkins POST jobs need to have a crumb to make a successful request, so before creation can happen a request to the server to retrieve a Jenkins-Crumb needs to happen. Once that crumb is retrieved, it can be passed along as a header and the job can be created with the modified config.xml. If the job was successfully created, an empty result set will be returned.

Parameters

Name Description
Template Job The name of the template job on the Jenkins server.
Name The name of the new Jenkins job.
Template Substitutions A JSON object mapped with the text to be substituted as the key and the text to use as the values - ie. {'GIT_LOCATION': 'http://github.com/user/repository'}

Sample Configuration

Name Description
Template Job Test Projects - Template
Name Test Projects - ACME
Template Substitutions {"COMPANY_NAME": "Acme","COMPANY_URL": "https://acme.com"}

Results

Name Description
Job URL Returns the URL of the newly created job if successfully created

Changelog

Jenkins Job Create From Template V1 (2017-10-03)

  • Initial version. See README for details.


Related Handlers