-
Notifications
You must be signed in to change notification settings - Fork 6
/
default.libsonnet
107 lines (101 loc) · 4.29 KB
/
default.libsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/******************************************************************************
* Copyright (c) 2020 Eclipse Foundation and others.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License 2.0
* which is available at http://www.eclipse.org/legal/epl-v20.html,
* or the MIT License which is available at https://opensource.org/licenses/MIT.
* SPDX-License-Identifier: EPL-2.0 OR MIT
*****************************************************************************/
{
spec: {
local thisSpec = self,
name: error "Provide agent name",
labels: [],
# Default is 'EXCLUSIVE'.
# 'NORMAL' means "utilize agent as much as possible"
# 'EXCLUSIVE' means "leave for tied jobs only".
# See https://javadoc.jenkins.io/hudson/model/Node.Mode.html
mode: "EXCLUSIVE",
username: "jenkins",
home: "/home/%s" % self.username,
agentWorkdir: self.home + "/jenkins-agent",
startupScript: "/usr/local/bin/jenkins-agent",
maxHeap: "256m",
docker: {
registry: "docker.io",
repository: "eclipsecbi",
image: "jiro-agent-%s" % thisSpec.name,
tag: "spec",
context: thisSpec.name,
raw_dockerfile:: error "Provide an dockerfile",
dockerfile: self.raw_dockerfile % thisSpec,
},
env: {
JENKINS_REMOTING_JAVA_OPTS: [
"-showversion",
"-XshowSettings:vm",
"-Xmx%s" % thisSpec.maxHeap,
"-Dorg.jenkinsci.remoting.engine.JnlpProtocol3.disabled=true",
# org.jenkinsci.plugins.gitclient.CliGitAPIImpl.useSETSID=true to allow git client to ssh clone to use passphrase protected keys
# https://github.com/jenkinsci/git-client-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L100
"-Dorg.jenkinsci.plugins.gitclient.CliGitAPIImpl.useSETSID=true"
],
OPENJ9_JAVA_OPTIONS: [
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:+IdleTuningCompactOnIdle",
"-XX:+IdleTuningGcOnIdle",
],
# Some parent images (from adoptopenjdk) define such an env. We disable them.
JAVA_TOOL_OPTIONS: [],
_JAVA_OPTIONS: [],
},
remoting_dockerfile:: importstr "remoting/Dockerfile",
},
local remotings = import "remoting/remoting.json",
variants: {
[variant.remoting.version]: variant for variant in [
{
remoting: {
version: releases.remotingVersion,
assert std.length(self.version) != 0: "Must specify remoting version",
# <jar> must match the path declared in the startupScript
# Look at the "-cp <jar>" for a given version
jar: "/usr/share/jenkins/agent.jar",
url: "https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/%s/remoting-%s.jar" % [ self.version, self.version, ],
startupScript: {
name: "jenkins-agent",
version: releases.startupScriptVersion,
assert std.length(self.version) != 0: "Must specify startupScript version",
url: "https://github.com/jenkinsci/docker-agent/raw/%s/%s" % [ self.version, self.name, ],
}
},
local this = self, # workaround to make objects available in nested objects below
docker: $.spec.docker + {
tag: "remoting-%s" % releases.remotingVersion,
aliases: if remotings.latest == releases.remotingVersion then [
"%s/%s/%s:%s" % [self.registry, self.repository, self.image, "latest"]
] else [],
dockerfile: $.spec.remoting_dockerfile % (
$.spec + {
from: "%s/%s/%s:%s" % [$.spec.docker.registry, $.spec.docker.repository, $.spec.docker.image, $.spec.docker.tag],
remotingJar: this.remoting.jar,
remotingJarUrl: this.remoting.url,
startupScriptUrl: this.remoting.startupScript.url,
}
),
},
} for releases in remotings.releases
]
},
addAliases(superVariants, names):: {
[variant]+: superVariants[variant] + {
docker+: {
aliases+: [
name % superVariants[variant].remoting.version for name in names
] + if remotings.latest == superVariants[variant].remoting.version then [
name % "latest" for name in names
] else [],
},
}, for variant in std.objectFields(superVariants)
},
}