-
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 #355 from abayer/jenkins-52259
[FIXED JENKINS-52259] Add yamlFile option for Declarative agent
- Loading branch information
Showing
13 changed files
with
215 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
label 'mypod' | ||
yamlFile 'examples/declarative_from_yaml_file/KubernetesPod.yaml' | ||
} | ||
} | ||
stages { | ||
stage('Run maven') { | ||
steps { | ||
sh 'set' | ||
sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}" | ||
container('maven') { | ||
sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' | ||
sh 'mvn -version' | ||
} | ||
container('busybox') { | ||
sh 'echo BUSYBOX_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' | ||
sh '/bin/busybox' | ||
} | ||
} | ||
} | ||
} | ||
} |
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,25 @@ | ||
metadata: | ||
labels: | ||
some-label: some-label-value | ||
spec: | ||
containers: | ||
- name: jnlp | ||
env: | ||
- name: CONTAINER_ENV_VAR | ||
value: jnlp | ||
- name: maven | ||
image: maven:3.3.9-jdk-8-alpine | ||
command: | ||
- cat | ||
tty: true | ||
env: | ||
- name: CONTAINER_ENV_VAR | ||
value: maven | ||
- name: busybox | ||
image: busybox | ||
command: | ||
- cat | ||
tty: true | ||
env: | ||
- name: CONTAINER_ENV_VAR | ||
value: busybox |
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
2 changes: 1 addition & 1 deletion
2
src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarative.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
3 changes: 2 additions & 1 deletion
3
...est/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeFromYaml.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
28 changes: 28 additions & 0 deletions
28
...resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeFromYamlFile.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,28 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
label 'declarativefromyamlfile-pod' | ||
yamlFile 'declarativeYamlFile.yml' | ||
} | ||
} | ||
options { | ||
// Because there's no way for the container to actually get at the git repo on the disk of the box we're running on. | ||
skipDefaultCheckout(true) | ||
} | ||
stages { | ||
stage('Run maven') { | ||
steps { | ||
sh 'set' | ||
sh "echo OUTSIDE_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}" | ||
container('maven') { | ||
sh 'echo MAVEN_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' | ||
sh 'mvn -version' | ||
} | ||
container('busybox') { | ||
sh 'echo BUSYBOX_CONTAINER_ENV_VAR = ${CONTAINER_ENV_VAR}' | ||
sh '/bin/busybox' | ||
} | ||
} | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/declarativeYamlFile.yml
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 @@ | ||
metadata: | ||
labels: | ||
some-label: some-label-value | ||
class: KubernetesDeclarativeAgentTest | ||
spec: | ||
containers: | ||
- name: jnlp | ||
env: | ||
- name: CONTAINER_ENV_VAR | ||
value: jnlp | ||
- name: maven | ||
image: maven:3.3.9-jdk-8-alpine | ||
command: | ||
- cat | ||
tty: true | ||
env: | ||
- name: CONTAINER_ENV_VAR | ||
value: maven | ||
- name: busybox | ||
image: busybox | ||
command: | ||
- cat | ||
tty: true | ||
env: | ||
- name: CONTAINER_ENV_VAR | ||
value: busybox |