Ageis
Ageis

Reputation: 2315

Change xml configuration file based on jenkins build variables

if i have the following manifest 
    <sitemanifest>
      <IisApp path="C:\Program Files (x86)\Jenkins\workspace\Single Sign On\Output\2.0.233.1258\QuickRelease" managedRuntimeVersion="v4.0"/>
      <setAcl path="C:\Program Files (x86)\Jenkins\workspace\Single Sign On\Output\2.0.233.1258\QuickRelease" setAclResourceType="Directory"  setAclUser="anonymousAuthenticationUser" /> 
    </sitemanifest>

Is it possible to inject build parameters from a jenkins job? This is useful for me since I can then have a dedicated jenkins job that executes a backup of the site before deploying to it.

It's then used by all my deployments so it's modular and repeatable.

Upvotes: 0

Views: 921

Answers (1)

ANIL
ANIL

Reputation: 2682

First, parameterize the paths in your manifest file like the following:

<sitemanifest>
      <IisApp path="$path" managedRuntimeVersion="v4.0"/>
      <setAcl path="$path1" setAclResourceType="Directory"  setAclUser="anonymousAuthenticationUser" /> 
</sitemanifest>

Then create a freestyle job in Jenkins and in job configuration in general section choose This project is parameterized and create two string parameters path and path1.

Then choose Execute Shell and add the following script into it and save the job:

envsubst '$path' < /path/to/manifest
envsubst '$path1' < /path/to/manifest

The envsubst program substitutes the values of variables.

then when you build the job it will ask for two parameters path and path1, provide the required path and build the job.

This should do the trick.

Upvotes: 1

Related Questions