diff --git a/jenkins/jenkins.nomad b/jenkins/jenkins.nomad index fc84bc6..0923903 100644 --- a/jenkins/jenkins.nomad +++ b/jenkins/jenkins.nomad @@ -1,28 +1,40 @@ +variable "jenkins_war" { + type = map(string) + default = { + war_version = "2.426.2" + war_sha256 = "3731b9f44973fbbf3e535f98a80c21aad9719cb4eea8a1e59e974c11fe846848" #pragma: allowlist secret + } + description = "Version of the Jenkins release to deploy" +} + +variable "plugin_manager" { + type = map(string) + default = { + version = "2.12.8" + } + description = "Map of configuration entries for the java plugin manager." +} + job "jenkins" { update { max_parallel = 1 health_check = "checks" - auto_revert = true + auto_revert = true auto_promote = true - canary = 1 - } - - constraint { - attribute = "${attr.unique.hostname}" - operator = "regexp" - value = "^turing.*" + canary = 1 } datacenters = ["dc1"] + type = "service" - group "main" { + + group "controller" { count = 1 network { - port "ui" { - static = "8080" - } - mode = "host" + port "ui" {} + // mode = "host" + port "agent" {} } volume "casc" { @@ -31,157 +43,150 @@ job "jenkins" { source = "jenkins_casc" } - task "controller" { + task "plugins" { driver = "exec" + env { + CASC_JENKINS_CONFIG = "alloc/data/jenkins.yml" + JENKINS_HOME = "alloc/jenkins" + CACHE_DIR = "local/" + } + lifecycle { + hook = "prestart" + sidecar = false + } volume_mount { volume = "casc" - destination = "/usr/share/jenkins" + destination = "/usr/share/jenkins/" read_only = false } artifact { - source = "https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/2.12.8/jenkins-plugin-manager-2.12.8.jar" + source = "https://github.com/jenkinsci/plugin-installation-manager-tool/releases/download/${var.plugin_manager.version}/jenkins-plugin-manager-${var.plugin_manager.version}.jar" destination = "alloc/data/jenkins-plugin-manager.jar" - mode = "file" + mode = "file" } artifact { - source = "https://get.jenkins.io/war-stable/2.346.1/jenkins.war" + source = "https://get.jenkins.io/war-stable/${var.jenkins_war.war_version}/jenkins.war" destination = "alloc/data/jenkins.war" - mode = "file" + mode = "file" options { - checksum = "sha256:176e2ce5c23d3c0b439befe0461e7ed1f53ac3091db05980198c23c7fde53b27" + checksum = "sha256:${var.jenkins_war.war_sha256}" } } + template { - data = "{{ key \"jenkins/plugins\" }}" - destination = "local/plugins.txt" + data = "{{ key \"nomad/jenkins/plugins\" }}" + destination = "alloc/data/plugins.txt" change_mode = "restart" } - env { - CASC_JENKINS_CONFIG = "alloc/data/jenkins.yml" - JENKINS_HOME = "/usr/share/jenkins" - CACHE_DIR = "local/" - } + template { - data = <