I think script {} is the answer...

On Friday, May 5, 2017 at 3:36:41 PM UTC-5, Guy Knights wrote:
>
> I've been playing around with the declarative pipeline syntax and I'm 
> having trouble running a docker container to do some processing. To 
> clarify, I *don't* want to run my entire pipeline in the container, I just 
> need to run a container to do some processing as part of the pipeline.
>
> I've had this working in a scripted pipeline like so:
>
> def webpack_builder = docker.image('webpack:latest').run("-v 
> \"${WORKSPACE}/gtp:/opt/gtp\" -v 
> \"/opt/gtp-images/${IMAGES_PATH}:/opt/gtp/app/images\" -e 
> \"GTP_DIR=/opt/gtp\" -e \"DO_BUILD=true\" -e \"CONFIG=webpack.config.js\" 
> -e \"ENVIRONMENT=production\"")
>
> def cid = webpack_builder.id
>
> sh """
>       set +x
>       docker logs -f ${cid}
>       if [ "\$(docker ps -a|sed -ne 
> 's/^.*Exited.*(\\([0-9]*\\)).*\$/\\1/p')" -eq 0 ]; then
>          docker stop ${cid} && docker rm ${cid}
>       else
>          echo "Webpack build failed"
>          docker stop ${cid}
>          exit 1
>       fi
> """
>
> However I tried transplanting this directly to the declarative pipeline 
> and it doesn't seem to work. I believe I could add it as a script { } 
> block, but this seems kludgy to me. Is there a way to transpose this to a 
> syntax that would work in a declarative pipeline? I found the docs not very 
> informative on this issue.
>
> Thanks,
> Guy
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/bb5ba064-a2ff-444d-8c72-05e2c1f75e7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to