There is a docker image whose name is IMAGE_NAME.
I want a Jenkins job to docker pull IMAGE_NAME
and then docker run IMAGE_NAME /bin/bash -c '/usr/bin/my_startup arg1 arg2 arg3
I tried a few variations of a Jenkinsfile based on some googled examples but they don’t work and I clearly don’t understand stages, agent, what environment the steps {sh '...'}
command runs in, or any of the Jenkins jargon at all.
What’s a minimal jenkinsfile which will pull IMAGE_NAME and run a command with arguments in it?
2
Answers
This worked:
Apparently this is a Pipeline script, run in a Groovy sandbox in Jenkins 2.150.1.
As long as this is not a "code golf" style question, the following pipeline will do the trick for you:
If you have a private and/or custom registry, then you will need the withRegistry block and a registry credentials plugin setup on the Jenkins main server.