forked from jenkinsci/kubernetes-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Declarative pipeline behavior example
Change-Id: I62c82b61f81e74fe31d8d961fe4cb3c099a354c6
- Loading branch information
Showing
5 changed files
with
176 additions
and
11 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
33 changes: 33 additions & 0 deletions
33
src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/sshagentfromyaml.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,33 @@ | ||
podTemplate(label: 'mypod', yaml: """ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
spec: | ||
containers: | ||
- name: ssh-client | ||
image: kroniak/ssh-client:3.6 | ||
command: | ||
- cat | ||
tty: true | ||
""" | ||
) | ||
{ | ||
node ('mypod') { | ||
stage('container log') { | ||
container('ssh-client') { | ||
sshagent (credentials: ['ContainerExecDecoratorPipelineTest-sshagent']) { | ||
sh 'env' | ||
sh 'ssh-add -L' | ||
sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com || exit 0' | ||
} | ||
} | ||
sshagent (credentials: ['ContainerExecDecoratorPipelineTest-sshagent']) { | ||
container('ssh-client') { | ||
sh 'env' | ||
sh 'ssh-add -L' | ||
sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com || exit 0' | ||
} | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/resources/org/csanchez/jenkins/plugins/kubernetes/pipeline/sshagentpipeline.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,36 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
label "sshagent" | ||
containerTemplate { | ||
name 'ssh-client' | ||
image 'kroniak/ssh-client:3.6' | ||
workingDir '/home/jenkins' | ||
ttyEnabled true | ||
command 'cat' | ||
} | ||
} | ||
} | ||
|
||
|
||
stages{ | ||
stage('container log') { | ||
steps{ | ||
container('ssh-client') { | ||
sshagent (credentials: ['ContainerExecDecoratorPipelineTest-sshagent']) { | ||
sh 'env' | ||
sh 'ssh-add -L' | ||
sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com || exit 0' | ||
} | ||
} | ||
sshagent (credentials: ['ContainerExecDecoratorPipelineTest-sshagent']) { | ||
container('ssh-client') { | ||
sh 'env' | ||
sh 'ssh-add -L' | ||
sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com || exit 0' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...esources/org/csanchez/jenkins/plugins/kubernetes/pipeline/sshagentpipelinefromyaml.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 @@ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
label "sshagent" | ||
yaml """ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
spec: | ||
containers: | ||
- name: ssh-client | ||
image: kroniak/ssh-client:3.6 | ||
command: | ||
- cat | ||
tty: true | ||
""" | ||
} | ||
} | ||
|
||
stages{ | ||
stage('container log') { | ||
steps{ | ||
container('ssh-client') { | ||
sshagent (credentials: ['ContainerExecDecoratorPipelineTest-sshagent']) { | ||
sh 'env' | ||
sh 'ssh-add -L' | ||
sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com || exit 0' | ||
} | ||
} | ||
sshagent (credentials: ['ContainerExecDecoratorPipelineTest-sshagent']) { | ||
container('ssh-client') { | ||
sh 'env' | ||
sh 'ssh-add -L' | ||
sh 'ssh -vT -o "StrictHostKeyChecking=no" git@github.com || exit 0' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |