Integrating ISPW with Jenkins

Adding Required Dependencies to Jenkins

If your Jenkins instance is installed on a Windows platform, it will be necessary to install the Powershell Plugin (https://wiki.jenkins-ci.org/display/JENKINS/PowerShell+Plugin). This plugin will be needed in order to make an outbound ReST request to the ISPW API. In order to install the plugin, click Manage Jenkins > Manage Plugins, then open the Available tab and search for “Powershell” and install the plugin. Jenkins may require a restart to complete installation.

NOTE: If the Jenkins instance is installed on a Unix or Linux platform, this plugin is not necessary. Instead, use the curl shell command.

Configuring Build

In this example, we’ll create a project called “Build_1”. This build won’t pull source down from a source control repository or actually build any binaries; we’re only using it for demonstration purposes. However, the steps we’ll add can be added to any existing build in your Jenkins configuration. We’ll be adding a script to Build_1 that will call the ISPW ReST API, deploy all the tasks in release myrlease currently in level dev1, and then configure 2 webhooks: one to build a different Jenkins project (Build_2) on a successful deploy, and one to disable that project on a failure.

From the Jenkins homepage, click “New Item”, give the item the name “Build_1”, select “Freestyle Project” from the menu, scroll down and hit “OK”. You’ll now be brought to the configuration page for the project. Scroll to the bottom and locate the “Build” section. In the “Add build step” dropdown, select Powershell (or Execute Shell on Unix/Linux). Add the following shell snippet (see general API documentation for curl version):

Example: Global basic authentication with one overridden callback using httpHeaders
$ispwJson = '{
  "runtimeConfiguration":"<runtime configuration>",
  "httpHeaders": [{
        "name":"Content-Type",
        "value":"application/json"}
  ],
  "events": [
   {"name":"Completed",
   },
    {"name":"Failed",
    }
  ]
}'
Invoke-Webrequest http://myces.corp/ispw/<ispw instance>/releases/<release>/tasks/deploy?level=dev1 -method POST -headers @{"Authorization"="<access token>"} -body $ispwJson -ContentType application/json -UseBasicParsing
 Finally, add a project call “Build_2″ just as we did with “Build_1“. This build needs no configuration, it exists just to be started/disabled by the webhook configured above.