Connect Spinnaker to Jenkins
Consult the Spinnaker documentation’s Jenkins page for an in-depth guide.
Enable Jenkins in Spinnaker
Add the following snippet to your SpinnakerService
manifest:
apiVersion: spinnaker.armory.io/v1alpha2
kind: SpinnakerService
metadata:
name: spinnaker
spec:
spinnakerConfig:
config:
ci:
jenkins:
enabled: true
Enable Jenkins using the Halyard command:
hal config ci jenkins enable
Create a User API Token in Jenkins
Spinnaker uses your Jenkins username and API token for authentication.
- Log into Jenkins
- Click on your username (in the top right)
- Click on “Configure” (on the left)
- Under the “API Token” section, click on “Add new Token”, and “Generate” and record the generated token
- Record your username; this is the value in the current page URL between ‘user’ and ‘configure’ (http://
/user/ /configure)
Add a Jenkins Master
You can add as many Jenkins masters as needed. Once the master is configured properly, Spinnaker will use the credentials provided to query for all available jobs and display them in the UI for triggers and stages.
Add the Jenkins master to Spinnaker:
Add the following snippet to your SpinnakerService
manifest:
apiVersion: spinnaker.armory.io/v1alpha2
kind: SpinnakerService
metadata:
name: spinnaker
spec:
spinnakerConfig:
config:
ci:
jenkins:
enabled: true
masters:
- name: <jenkins-master-name>
address: https://<jenkins-url>/ # The address your jenkins master is reachable at.
username: <jenkins-username> # The username of the jenkins user to authenticate as.
password: abc # The password of the jenkins user to authenticate as. This field support "encrypted" secret references.
Don’t forget to apply your changes:
kubectl -n >spinnaker namespace> apply -f <SpinnakerService manifest>
hal config ci jenkins master add <jenkins-master-name> \
--address https://<jenkins-url>/ \
--username <jenkins-username> \
--password # You will be prompted for your Jenkins API token interactively
Apply your changes using hal deploy apply
.
Troubleshooting Authentication / Connectivity
Igor is the service that interacts with Jenkins. You can test Spinnaker-Jenkins connectivity using curl
from another pod. The Deck or Clouddriver pod is a good option since curl
is already installed there.
curl https://<jenkins-url>/api/json --user <jenkins-username>:<jenkins-api-token>
This returns a JSON list of jobs.
For example:
# Exec into the Clouddriver container:
kubectl exec -it spin-clouddriver-6cf45f4db-lkg7t bash
bash-4.4$ curl https://jenkins.domain.com/api/json --user justin:1234567890abcdefghijklmnopqrstuvwx
{"_class":"hudson.model.Hudson","assignedLabels":[{"name":"master"}], [...] }
Feedback
Was this page helpful?
Thank you for letting us know!
Sorry to hear that. Please tell us how we can improve.
Last modified April 12, 2021: (8405118)