Skip to content

Instantly share code, notes, and snippets.

@jmaitrehenry
Created April 26, 2017 14:40
Show Gist options
  • Select an option

  • Save jmaitrehenry/7eb2651aaff90738fdbccae74eb1c92b to your computer and use it in GitHub Desktop.

Select an option

Save jmaitrehenry/7eb2651aaff90738fdbccae74eb1c92b to your computer and use it in GitHub Desktop.
resources:
- name: {{properties['buildName']}}-tpl
properties:
description: ''
properties:
disks:
- autoDelete: true
boot: true
deviceName: boot
initializeParams:
sourceImage: projects/PROJECT/global/images/jenkins-coreos
mode: READ_WRITE
type: PERSISTENT
machineType: n1-standard-4
networkInterfaces:
- accessConfigs:
- name: external-nat
type: ONE_TO_ONE_NAT
network: global/networks/default
# scheduling:
# preemptible: true
metadata:
items:
- key: user-data
value: |
#cloud-config
write_files:
- path: /tmp/startup.sh
permissions: 0755
content: |
#!/bin/bash
sleep 10
export JENKINS_URL='http://JENKINS-URL'
export USER='USER:TOKEN'
export LABELS='{{properties['buildName']}}'
export SLAVE_NAME="{{properties['buildName']}}-`/usr/bin/hostname`"
systemctl stop update-engine
chmod 777 /var/run/docker.sock
mkdir /tmp/jenkins
chmod 777 /tmp/jenkins
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 \
-v /tmp/jenkins:/tmp/jenkins \
jmaitrehenry/docker-jenkins-jnlp
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
type: compute.v1.instanceTemplate
- name: {{properties['buildName']}}-igm
type: compute.v1.instanceGroupManager
properties:
baseInstanceName: {{properties['buildName']}}-igm
instanceTemplate: $(ref.{{properties['buildName']}}-tpl.selfLink)
targetSize: {{properties['targetSize']}}
zone: us-central1-f
@jmaitrehenry
Copy link
Author

gce.jinja.schema:

properties:
  targetSize:
    type: integer
  buildName:
    type: string
  buildId:
    type: integer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment