Skip to content

Instantly share code, notes, and snippets.

@jmaitrehenry
Created November 28, 2017 16:04
Show Gist options
  • Select an option

  • Save jmaitrehenry/13303ea2af64b91ebada07395b1a6123 to your computer and use it in GitHub Desktop.

Select an option

Save jmaitrehenry/13303ea2af64b91ebada07395b1a6123 to your computer and use it in GitHub Desktop.
#cloud-config
write_files:
- path: /tmp/startup.sh
permissions: 0755
content: |
#!/bin/bash
sleep 10
export JENKINS_URL='xxx'
export USER='yyy'
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
{% if properties['dockerToken'] is defined %}
- path: /home/core/.docker/config.json
content: |
{
"auths": {
"": {"auth": "{{properties[dockerToken]}}"}
}
}
{% endif %}
- path: /ci/jenkins/gcloud/configurations/config_default
content: |
[core]
account = ark
project = bleuh
[compute]
zone = us-east1-d
region = us-east1
- path: /ci/jenkins/gcloud/credentials
content: |
{
"data": [
{
"credential": {
"_class": "OAuth2Credentials",
"_module": "oauth2client.client",
"access_token": "hum.....",
"client_id": "XD.apps.googleusercontent.com",
"client_secret": "trop",
"id_token": {
"at_hash": "de",
"aud": "hard.apps.googleusercontent.com",
"azp": "coding.apps.googleusercontent.com",
"email": "me.semble",
"email_verified": true,
"exp": 1498585070,
"hd": "dans",
"iat": 1498581470,
"iss": "accounts.google.com",
"sub": "ce_fichier"
},
"invalid": false,
"refresh_token": "faudrait",
"revoke_uri": "https://accounts.google.com/o/oauth2/revoke",
"scopes": [
"https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/appengine.admin",
"https://www.googleapis.com/auth/accounts.reauth"
],
"token_expiry": "2017-06-27T17:37:50Z",
"token_info_uri": "https://www.googleapis.com/oauth2/v3/tokeninfo",
"token_response": {
"access_token": "vraiement",
"expires_in": 3600,
"id_token": "refaire_ca",
"token_type": "Bearer"
},
"token_uri": "https://accounts.google.com/o/oauth2/token",
"user_agent": "google-cloud-sdk"
},
"key": {
"account": "[email protected]",
"type": "google-cloud-sdk"
}
}
],
"file_version": 1
}
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