Last active
July 26, 2017 20:13
-
-
Save scoheb/d93a48600e5c1314378fd5bac934e685 to your computer and use it in GitHub Desktop.
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
podTemplate(name: 'some-slave', label: 'some-slave', cloud: 'openshift', serviceAccount: 'jenkins', | |
containers: [ | |
// This adds the custom slave container to the pod. Must be first with name 'jnlp' | |
containerTemplate(name: 'jnlp', | |
image: '172.30.1.1:5000/continuous-infra/jenkins-continuous-infra-slave:latest', | |
ttyEnabled: false, | |
args: '${computer.jnlpmac} ${computer.name}', | |
command: '', | |
workingDir: '/tmp'), | |
// This adds the rpmbuild container to the pod. | |
containerTemplate(name: 'rpmbuild', | |
image: '172.30.1.1:5000/ci-containers/rpmbuild', | |
ttyEnabled: false, | |
command: '', | |
workingDir: '/tmp'), | |
], | |
// This mounts a volume that is accessible from containers | |
volumes: [emptyDirVolume(memory: false, mountPath: '/results')]) { | |
node('some-slave') { | |
// This variable will be available in the container | |
stage = "rpmbuild" | |
// This variable will contain a return string from | |
// the container execution | |
containerReturnValue = "" | |
stage(stage) { | |
sh 'ls -l /results' | |
container('rpmbuild') { | |
// Here is the variable being passed in... | |
// and we add it to a file that will be available | |
// after we are done with container. | |
sh '/bin/echo stage:' + stage + ' > /results/1.txt' | |
// The shell step captures some output and assigns it | |
// to a variable | |
containerReturnValue = sh(script: 'id -u', returnStdout: true).trim() | |
} | |
echo "containerReturnValue: " + containerReturnValue | |
sh 'ls -l /results' | |
// We should see stage:rpmbuild here in 1.txt | |
sh 'cat /results/1.txt' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Resulting log