-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from Vlatombe/JENKINS-50196
[JENKINS-50196] Fix nested Pod Templates support
- Loading branch information
Showing
8 changed files
with
130 additions
and
20 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
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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateContext.java
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,26 @@ | ||
package org.csanchez.jenkins.plugins.kubernetes.pipeline; | ||
|
||
import java.io.Serializable; | ||
|
||
/** | ||
* Context object for PodTemplate during pipeline execution | ||
*/ | ||
public class PodTemplateContext implements Serializable { | ||
private static final long serialVersionUID = 3065143885759619305L; | ||
|
||
private final String namespace; | ||
private final String name; | ||
|
||
public PodTemplateContext(String namespace, String name) { | ||
this.namespace = namespace; | ||
this.name = name; | ||
} | ||
|
||
public String getNamespace() { | ||
return namespace; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/runIn2Pods.groovy
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,40 @@ | ||
podTemplate(label: 'mypod', containers: [ | ||
containerTemplate(name: 'busybox', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), | ||
]) { | ||
semaphore 'podTemplate1' | ||
node ('mypod') { | ||
semaphore 'pod1' | ||
stage('Run') { | ||
container('busybox') { | ||
sh """ | ||
## durable-task plugin generates a script.sh file. | ||
## | ||
echo "script file: \$(find ../../.. -iname script.sh))" | ||
echo "script file contents: \$(find ../../.. -iname script.sh -exec cat {} \\;)" | ||
test -n "\$(cat \$(find ../../.. -iname script.sh))" | ||
""" | ||
} | ||
} | ||
} | ||
} | ||
|
||
podTemplate(label: 'mypod2', containers: [ | ||
containerTemplate(name: 'busybox2', image: 'busybox', ttyEnabled: true, command: '/bin/cat'), | ||
]) { | ||
semaphore 'podTemplate2' | ||
node ('mypod2') { | ||
semaphore 'pod2' | ||
stage('Run') { | ||
container('busybox2') { | ||
|
||
sh """ | ||
## durable-task plugin generates a script.sh file. | ||
## | ||
echo "script file: \$(find ../../.. -iname script.sh))" | ||
echo "script file contents: \$(find ../../.. -iname script.sh -exec cat {} \\;)" | ||
test -n "\$(cat \$(find ../../.. -iname script.sh))" | ||
""" | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.