Skip to content
Permalink
Browse files

[FIXED JENKINS-38242] Add the ability to specify agent parameters (do…

…cker)
  • Loading branch information...
Peter Leibiger
Peter Leibiger committed Sep 20, 2016
1 parent 7ae4f28 commit df6eaddfa1fe293f0727d0417082833774647929
@@ -45,6 +45,9 @@ public class Agent implements Serializable {
@Whitelisted
String label

@Whitelisted
String args

@Whitelisted
Boolean any

@@ -56,6 +59,9 @@ public class Agent implements Serializable {
if (args.containsKey("label")) {
label = args.get("label")
}
if (args.containsKey("args")) {
this.args = args.get("args")
}
}

@Whitelisted
@@ -70,6 +76,6 @@ public class Agent implements Serializable {

// TODO: Rewrite as an extension point and get this by extension discovery, but we knew that already.
public static List<String> agentConfigKeys() {
return ["docker", "label"]
return ["docker", "label", "args"]
}
}
@@ -214,9 +214,9 @@ public class ModelInterpreter implements Serializable {
def dockerOrWithout(Agent agent, Closure body) {
if (agent.docker != null) {
return {
script.getProperty("docker").image(agent.docker).inside {
script.getProperty("docker").image(agent.docker).inside(agent.args, {
body.call()
}
})
}
} else {
return {
@@ -240,4 +240,4 @@ public class ModelInterpreter implements Serializable {
}
}
}
}
}
@@ -87,6 +87,7 @@ public void agentDocker() throws Exception {
j.assertBuildStatusSuccess(j.waitForCompletion(b));
j.assertLogContains("[Pipeline] { (foo)", b);
j.assertLogContains("The answer is 42", b);
j.assertLogContains("-v /tmp:/tmp", b);
}

@Test
@@ -23,7 +23,7 @@
*/

pipeline {
agent docker:"httpd:2.4.12"
agent docker:"httpd:2.4.12", args:"-v /tmp:/tmp"
stages {
stage("foo") {
sh 'cat /usr/local/apache2/conf/extra/httpd-userdir.conf'

0 comments on commit df6eadd

Please sign in to comment.
You can’t perform that action at this time.