Created
July 25, 2017 21:56
-
-
Save scoheb/4a1cb5bf5f646c1270deb9c91d73604e 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: 'continous-infra-slave', label: 'continous-infra-slave', cloud: 'openshift', | |
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', | |
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('continous-infra-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