-
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.
[JENKINS-57548] Explicit inheritance should override implicit inherit…
…ance
- Loading branch information
Showing
7 changed files
with
122 additions
and
3 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
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
51 changes: 51 additions & 0 deletions
51
...nchez/jenkins/plugins/kubernetes/pipeline/declarativeWithNestedExplicitInheritance.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,51 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
label 'parent-pod' | ||
yaml """ | ||
spec: | ||
containers: | ||
- name: golang | ||
image: golang:1.6.3-alpine | ||
command: | ||
- cat | ||
tty: true | ||
""" | ||
} | ||
} | ||
stages { | ||
stage('Run maven') { | ||
agent { | ||
kubernetes { | ||
inheritFrom '' | ||
label 'nested-pod' | ||
yaml """ | ||
spec: | ||
containers: | ||
- name: maven | ||
image: maven:3.3.9-jdk-8-alpine | ||
command: | ||
- cat | ||
tty: true | ||
""" | ||
} | ||
} | ||
steps { | ||
container('maven') { | ||
sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' | ||
sh 'mvn -version' | ||
} | ||
container('golang') { | ||
script { | ||
try { | ||
sh "go version" | ||
error("Should not inherit") | ||
} catch (e) { | ||
// ignored | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ces/org/csanchez/jenkins/plugins/kubernetes/pipeline/runInPodNestedExplicitInherit.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,29 @@ | ||
podTemplate(label: 'runInPodNestedExplicitInherit1', containers: [ | ||
containerTemplate(name: 'golang', image: 'golang:1.6.3-alpine', ttyEnabled: true, command: '/bin/cat'), | ||
]) { | ||
|
||
podTemplate(label: 'runInPodNestedExplicitInherit', inheritFrom: '', containers: [ | ||
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: '/bin/cat'), | ||
]) { | ||
|
||
node ('runInPodNestedExplicitInherit') { | ||
stage('Nested') { | ||
container('maven') { | ||
sh "mvn -version" | ||
} | ||
} | ||
stage('Parent') { | ||
container('golang') { | ||
script { | ||
try { | ||
sh "go version" | ||
error("Should not inherit") | ||
} catch (e) { | ||
// ignored | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |