{"__v":22,"_id":"5769809d47693a0e00002bcd","category":{"__v":3,"_id":"56ce1e6ee538330b0021ac5d","pages":["56ce1ec2f3539413004711ee","56ce1edef3539413004711f1","56ce2072e538330b0021ac62"],"project":"55c6bec1b9aa4e0d0016c2c3","version":"55c6bec1b9aa4e0d0016c2c6","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-02-24T21:19:42.029Z","from_sync":false,"order":1,"slug":"tools","title":"Installation"},"parentDoc":null,"project":"55c6bec1b9aa4e0d0016c2c3","user":"56e097457e2c420e008da356","version":{"__v":8,"_id":"55c6bec1b9aa4e0d0016c2c6","project":"55c6bec1b9aa4e0d0016c2c3","createdAt":"2015-08-09T02:45:21.683Z","releaseDate":"2015-08-09T02:45:21.683Z","categories":["55c6bec2b9aa4e0d0016c2c7","56c14bc5826df10d00e82230","56cceed8723ad71d00cae46c","56ccf29a431ada1f00e85aae","56ccf3c28fa8b01b00b82018","56ce1e6ee538330b0021ac5d","56f97e9a4c612020008f2eaf","5734fafd146eb82000597261"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["580cd8834495060f008add55","580d70f5a763ed0f008458e7"],"next":{"pages":[],"description":""},"createdAt":"2016-06-21T17:59:57.765Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":8,"body":"### Purpose\n\nThe purpose of this document is to provide instructions on how\nto set up and run the Jenkins script execution stage in Spinnaker (referred to as \"script stage\").\n\nThe script stage lets a Spinnaker user run an arbitrary shell, python, or \ngroovy script on a Jenkins instance as a first class stage in Spinnaker.\nThis is good for launching an integration/functional test battery\n after a bake and deploy stage from a pipeline instead of doing it manually.\n\n### Assumptions\n\nThere are a few assumptions we make in the following directions:\n\n* You have a running Spinnaker instance, with access to configuration files.\n\n* You have a running Jenkins instance at `<jenkins_host>`, with a user profile set up with admin access.\n\n\n### Configuring Jenkins\n\n* `ssh` into your Jenkins machine.\n\n* `wget` or `curl` the [raw job xml config file](https://storage.googleapis.com/jenkins-script-stage-config/scriptJobConfig.xml).\n\n* To create the Jenkins job, run:\n```shell\ncurl -X POST -H \"Content-Type: application/xml\" -d :::at:::scriptJobConfig.xml \\\n\"http://<username>:<user_api_token>@<jenkins_host>/jenkins/createItem?name=<JOB_Name>\"\n```\nwhere `<JOB_NAME>` is the name of the Jenkins job you create, e.g. \"runSpinnakerScript\"\nand `<user_api_token>` is the API token for your user, located at \"/user/`<username>`/configure\".\n\n* In the job config in the Jenkins UI, set the GitHub repository containing your scripts as\nwell as the git credentials.\n\n* In the UI, go to \"Manage Jenkins\" >> \"Configure System\" and set your git `user.name` and `user.email`.\n\nAt this point, you should be able to manually run the script job in Jenkins\n(with parameters) and see it succeed.\n\n### Configuring Spinnaker\n\n* Enable Igor.\n\n* In `spinnaker-local.yml`, set:\n  - `jenkins.enabled = true`\n  - `jenkins.masters[0].name = <jenkins_name>`\n  - `jenkins.masters[0].address = http://<jenkins_host>/jenkins` Note that \"/jenkins\" might not be the base path, it depends on how Jenkins is configured.\n  - `jenkins.masters[0].username = <username>`\n  - `jenkins.masters[0].password = <user_api_token>`\n\n* In `orca.yml`, add:\n```yml\nscript:\n    master: <jenkins_name> # name of Jenkins master in Spinnaker\n    job: <JOB_NAME> # from Jenkins job configuration\n```\n\n* Restart Orca and Igor if you didn't have a Jenkins master\nconfigured in Spinnaker.\n\n### Summary\n\nYou should now be able to add a stage called \"Script\" to your pipelines,\nwhere you can specify:\n\n* Repository Url: git repository housing your scripts.\n* Script path: path from the root of your git repository to your script's\ndirectory.\n* Command: name of the script with arguments to run.\n\nAmong other environment parameters (e.g. image, account, etc).\n\nThe current version of the script stage is a bit rudimentary, but we'll\nsoon have support for a separate \"job\" stage that will be much more robust and encapsulate\nthe same behavior as the script stage. The script stage is a temporary\nsolution for the time being.","excerpt":"Provide instructions for how to set up and run the Jenkins script execution stage in Spinnaker.","slug":"jenkins-script-execution-stage","type":"basic","title":"Jenkins Script Execution Stage"}

Jenkins Script Execution Stage

Provide instructions for how to set up and run the Jenkins script execution stage in Spinnaker.

### Purpose The purpose of this document is to provide instructions on how to set up and run the Jenkins script execution stage in Spinnaker (referred to as "script stage"). The script stage lets a Spinnaker user run an arbitrary shell, python, or groovy script on a Jenkins instance as a first class stage in Spinnaker. This is good for launching an integration/functional test battery after a bake and deploy stage from a pipeline instead of doing it manually. ### Assumptions There are a few assumptions we make in the following directions: * You have a running Spinnaker instance, with access to configuration files. * You have a running Jenkins instance at `<jenkins_host>`, with a user profile set up with admin access. ### Configuring Jenkins * `ssh` into your Jenkins machine. * `wget` or `curl` the [raw job xml config file](https://storage.googleapis.com/jenkins-script-stage-config/scriptJobConfig.xml). * To create the Jenkins job, run: ```shell curl -X POST -H "Content-Type: application/xml" -d @scriptJobConfig.xml \ "http://<username>:<user_api_token>@<jenkins_host>/jenkins/createItem?name=<JOB_Name>" ``` where `<JOB_NAME>` is the name of the Jenkins job you create, e.g. "runSpinnakerScript" and `<user_api_token>` is the API token for your user, located at "/user/`<username>`/configure". * In the job config in the Jenkins UI, set the GitHub repository containing your scripts as well as the git credentials. * In the UI, go to "Manage Jenkins" >> "Configure System" and set your git `user.name` and `user.email`. At this point, you should be able to manually run the script job in Jenkins (with parameters) and see it succeed. ### Configuring Spinnaker * Enable Igor. * In `spinnaker-local.yml`, set: - `jenkins.enabled = true` - `jenkins.masters[0].name = <jenkins_name>` - `jenkins.masters[0].address = http://<jenkins_host>/jenkins` Note that "/jenkins" might not be the base path, it depends on how Jenkins is configured. - `jenkins.masters[0].username = <username>` - `jenkins.masters[0].password = <user_api_token>` * In `orca.yml`, add: ```yml script: master: <jenkins_name> # name of Jenkins master in Spinnaker job: <JOB_NAME> # from Jenkins job configuration ``` * Restart Orca and Igor if you didn't have a Jenkins master configured in Spinnaker. ### Summary You should now be able to add a stage called "Script" to your pipelines, where you can specify: * Repository Url: git repository housing your scripts. * Script path: path from the root of your git repository to your script's directory. * Command: name of the script with arguments to run. Among other environment parameters (e.g. image, account, etc). The current version of the script stage is a bit rudimentary, but we'll soon have support for a separate "job" stage that will be much more robust and encapsulate the same behavior as the script stage. The script stage is a temporary solution for the time being.