Using inline bash commands as a task

671 views
Skip to first unread message

Hugh Acland

unread,
Jul 14, 2016, 1:43:56 PM7/14/16
to go-cd
Hi

I want to commit a running docker image as a task and use the git head hash for the tag name. In bash I would do this:









docker commit 8d from/remote-animal:$(git rev-parse HEAD | cut -c1-10)


However when I use this command in Go-Cd task it does not like it. How can I achieve this? I guess one way is to have a script on the agent and the call this script, but then this kinda means having to have gotten the script onto the agent in the first place. I thought the whole point of agents is that they are ephemeral? 

thanks

Ashwanth Kumar

unread,
Jul 14, 2016, 1:50:47 PM7/14/16
to go...@googlegroups.com
GoCD's Custom task doesn't run inside a shell unfortunately. We also do something like this in our pipelines
<exec command="bash">
  <arg>-c</arg>
  <arg>docker commit 8d from/remote-animal:$(git rev-parse HEAD | cut -c1-10)</arg>
  <runif status="passed" />
</exec>



--
You received this message because you are subscribed to the Google Groups "go-cd" group.
To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Ashwanth Kumar / ashwanthkumar.in

Hugh Acland

unread,
Jul 14, 2016, 2:03:17 PM7/14/16
to go-cd, ashwan...@googlemail.com
Thanks! You are a genius! Most helpful
Reply all
Reply to author
Forward
0 new messages