-
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 #1486 from Vlatombe/container-withMaven-env
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 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
31 changes: 31 additions & 0 deletions
31
...ces/org/csanchez/jenkins/plugins/kubernetes/pipeline/containerEnvironmentIsHonored.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,31 @@ | ||
podTemplate(yaml: ''' | ||
spec: | ||
containers: | ||
- name: jnlp | ||
image: jenkins/inbound-agent:3192.v713e3b_039fb_e-1 | ||
# PATH=/opt/java/openjdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
- name: alpine | ||
image: alpine:3.19.0 | ||
# PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | ||
command: | ||
- sleep | ||
args: | ||
- infinity | ||
''') { | ||
node(POD_LABEL) { | ||
echo "from Groovy outside container: ${env.PATH}" | ||
sh 'echo "from shell outside container: $PATH"' | ||
withEnv(['PATH+foo=/bar']) { | ||
echo "from Groovy outside container with override: ${env.PATH}" | ||
sh 'echo "from shell outside container with override: $PATH"' | ||
} | ||
container('alpine') { | ||
echo "from Groovy inside container: ${env.PATH}" | ||
sh 'echo "from shell inside container: $PATH"' | ||
withEnv(['PATH+foo=/bar']) { | ||
echo "from Groovy inside container with override: ${env.PATH}" | ||
sh 'echo "from shell inside container with override: $PATH"' | ||
} | ||
} | ||
} | ||
} |