Skip to content

Commit

Permalink
[FIXED JENKINS-38242] Add the ability to specify agent parameters (do…
Browse files Browse the repository at this point in the history
…cker)
  • Loading branch information
Peter Leibiger committed Sep 20, 2016
1 parent 7ae4f28 commit df6eadd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Expand Up @@ -45,6 +45,9 @@ public class Agent implements Serializable {
@Whitelisted
String label

@Whitelisted
String args

@Whitelisted
Boolean any

Expand All @@ -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
Expand All @@ -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"]
}
}
Expand Up @@ -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 {
Expand All @@ -240,4 +240,4 @@ public class ModelInterpreter implements Serializable {
}
}
}
}
}
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/agentDocker.groovy
Expand Up @@ -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'
Expand Down

0 comments on commit df6eadd

Please sign in to comment.