Thanks very much for this :) On Tuesday, September 12, 2017 at 5:42:03 PM UTC+1, Joshua Noble wrote: > > With declarative pipelines this is pretty straight forward, just build the > Docker image like you would on your local machine using `sh` commands. > > For example, in our cluster all build agents are actually the same, but > most builds run inside of a container on one of these nodes, which you've > noted (correctly) that you don't want to do, since you want to build an > image. We've simply given the "docker" label to our build agents, and our > declarative Jenkinsfile's use that label under the agent option. > > For example, you could use the following Jenkinsfile to build your-app. > Note that I'm using a GIT_SHA variable here which actually doesn't resolve, > but you could easily write a pipeline shared library to provide this info. > In addition, I only like to publish master branch builds on some repos in > order to save space in our registry. You can even tell Jenkins to use > specific credentials when pushing. > > pipeline { > agent { label 'docker' } > options { > ansiColor colorMapName: 'XTerm' > } > stages { > stage('Build') { > steps { > sh "docker build -t > registry.yourcompany.com/company/your-app:${GIT_SHA} > <http://registry.yourcompany.com/company/your-app:$%7BGIT_SHA%7D> ." > } > } > stage('Publish') { > when { > branch 'master' > } > steps { > withDockerRegistry([credentialsId: 'registry-creds', url: ' > https://registry.yourcompany.com']) { > sh "docker push > registry.yourcompany.com/company/your-app:${GIT_SHA} > <http://registry.yourcompany.com/company/your-app:$%7BGIT_SHA%7D>" > } > } > } > } > } > > > > > On Tuesday, February 14, 2017 at 2:32:56 PM UTC-5, Thomas Fjellstrom wrote: >> >> Hi, >> >> I'm brand new to jenkins, and have been reading a lot about the pipeline >> plugin. I think I have a basic grasp of it, but I haven't been able to >> figure out the proper syntax to build docker images in a pipeline stage. I >> don't want to run the steps IN a docker container, but rather build >> containers (multiple containers) in a pipeline Jenkinsfile. I also have >> some other requirements, like accessing credentials setup in the jenkins >> interface, and a private docker registry. >> >> Any help would be appreciated. >> >
-- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/3ecddc6c-b373-4b23-b11f-9bb8525e7198%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.