Created
September 3, 2017 15:53
-
-
Save jmaitrehenry/8fcae7198c250719172263dd0e7bf17b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cloud-config | |
write_files: | |
- path: /tmp/startup.sh | |
permissions: 0755 | |
content: | | |
#!/bin/bash | |
sleep 10 | |
export JENKINS_URL='http://master' | |
export USER='user:api_key' | |
export LABELS='{{properties['buildName']}}' | |
export SLAVE_NAME="{{properties['buildName']}}-`/usr/bin/hostname`" | |
systemctl stop update-engine | |
chmod 777 /var/run/docker.sock | |
mkdir /ci/jenkins | |
chmod 777 /ci/jenkins | |
sleep 10 | |
docker pull jmaitrehenry/docker-jenkins-jnlp | |
docker run -d -v /var/run/docker.sock:/var/run/docker.sock \ | |
-e JENKINS_URL=$JENKINS_URL \ | |
-e LABELS=$LABELS \ | |
-e USER=$USER \ | |
-e JENKINS_AGENT_NAME=$SLAVE_NAME \ | |
-e EXECUTORS=1 \{% if properties['dockerPreloadImage'] %} | |
-e DOCKER_PRELOAD_IMAGES='{{properties['dockerPreloadImage']}}' \{% endif %} | |
-v /ci/jenkins:/ci/jenkins \ | |
jmaitrehenry/docker-jenkins-jnlp | |
- path: /home/core/.docker/config.json | |
content: | | |
{ | |
"auths": { | |
"": {"auth": "{{properties[dockerToken]}}"} | |
} | |
} | |
coreos: | |
update: | |
reboot-strategy: "off" | |
units: | |
- name: "jenkins-startup.service" | |
command: "start" | |
content: | | |
[Unit] | |
Description=Jenkins container | |
Author=Me | |
After=docker.service | |
[Service] | |
ExecStart=/tmp/startup.sh | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment