-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Jenkins as code example to autostart jenkins workers as nomad batch j…
…obs (#82) * importing minimal jasc setup for nomad jenkins workers * fix: general cleanup Signed-off-by: Bram Vogelaar <[email protected]>
- Loading branch information
1 parent
16c567d
commit e75e53c
Showing
5 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
docker_jenkins_env_vars = { | ||
"java_opts": "-Djava.awt.headless=true -Djenkins.install.runSetupWizard=false", | ||
} | ||
jasc_config = <<EOF | ||
jenkins: | ||
agentProtocols: | ||
- "JNLP4-connect" | ||
- "Ping" | ||
clouds: | ||
- nomad: | ||
name: "nomad" | ||
nomadUrl: "http://{{ env "attr.unique.network.ip-address" }}:4646" | ||
prune: true | ||
templates: | ||
- idleTerminationInMinutes: 10 | ||
jobTemplate: |- | ||
{ | ||
"Job": { | ||
"Region": "global", | ||
"ID": "%WORKER_NAME%", | ||
"Type": "batch", | ||
"Datacenters": [ | ||
"dc1" | ||
], | ||
"TaskGroups": [ | ||
{ | ||
"Name": "jenkins-worker-taskgroup", | ||
"Count": 1, | ||
"RestartPolicy": { | ||
"Attempts": 0, | ||
"Interval": 10000000000, | ||
"Mode": "fail", | ||
"Delay": 1000000000 | ||
}, | ||
"Tasks": [ | ||
{ | ||
"Name": "jenkins-worker", | ||
"Driver": "docker", | ||
"Config": { | ||
"image": "jenkins/inbound-agent" | ||
}, | ||
"Env": { | ||
"JENKINS_URL": "http://{{ env "NOMAD_ADDR_http" }}", | ||
"JENKINS_AGENT_NAME": "%WORKER_NAME%", | ||
"JENKINS_SECRET": "%WORKER_SECRET%", | ||
"JENKINS_TUNNEL": "{{ env "NOMAD_ADDR_jnlp" }}" | ||
}, | ||
"Resources": { | ||
"CPU": 500, | ||
"MemoryMB": 256 | ||
} | ||
} | ||
], | ||
"EphemeralDisk": { | ||
"SizeMB": 300 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
labels: "nomad" | ||
numExecutors: 1 | ||
prefix: "jenkins" | ||
reusable: true | ||
tlsEnabled: false | ||
workerTimeout: 1 | ||
numExecutors: 0 | ||
jobs: | ||
- script: > | ||
job('nomad') { | ||
label('nomad') | ||
steps { | ||
shell('whoami') | ||
} | ||
} | ||
EOF | ||
plugins = ["configuration-as-code", "hashicorp-vault-plugin", "job-dsl", "nomad"] | ||
register_consul_service = true | ||
volume_name = "jenkins" |
File renamed without changes.
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