use Standard GoCD environment variables in gocd pipeline task

75 views
Skip to first unread message

Martin c

unread,
May 9, 2019, 10:21:25 AM5/9/19
to go-cd
Is it possible to use the Standard GoCD environment variables in a gocd pipeline? I'm trying to use it in a task e.g. $GO_PIPELINE_COUNTER or %GO_PIPELINE_COUNTER% but can't get it to work 

Chris Flynn

unread,
May 9, 2019, 10:30:50 AM5/9/19
to go...@googlegroups.com
What type of task are you using? I think you have to use a *bash* task and pass it in as part of the arguments section. Does this help? https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html

On Thu, May 9, 2019 at 10:21 AM Martin c <martin....@kurtgeiger.com> wrote:
Is it possible to use the Standard GoCD environment variables in a gocd pipeline? I'm trying to use it in a task e.g. $GO_PIPELINE_COUNTER or %GO_PIPELINE_COUNTER% but can't get it to work 

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/4bbf087f-b640-40a6-8ff1-f2eb4cfee917%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin c

unread,
May 9, 2019, 10:33:58 AM5/9/19
to go-cd
it's a custom task command running curl and I need to pass the variable as one of the arguments
e.g. 
command: curl
arguments: zyx<GO_PIPELINE_COUNTER var>


On Thursday, May 9, 2019 at 3:30:50 PM UTC+1, Chris Flynn wrote:
What type of task are you using? I think you have to use a *bash* task and pass it in as part of the arguments section. Does this help? https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html

On Thu, May 9, 2019 at 10:21 AM Martin c <martin...@kurtgeiger.com> wrote:
Is it possible to use the Standard GoCD environment variables in a gocd pipeline? I'm trying to use it in a task e.g. $GO_PIPELINE_COUNTER or %GO_PIPELINE_COUNTER% but can't get it to work 

--
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...@googlegroups.com.

Martin c

unread,
May 9, 2019, 10:45:38 AM5/9/19
to go-cd
even doing something like
command: sh
arguments: -c
curl xyz $GO_PIPELINE_COUNTER

doesn't work

Chris Flynn

unread,
May 9, 2019, 10:50:16 AM5/9/19
to go...@googlegroups.com
It seems like that page is exactly what you need. Is it not working? Do you get an error message? What does the task and output look like?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/241ad867-b9ee-43db-9c40-2007dd14ebb3%40googlegroups.com.
Message has been deleted

Martin c

unread,
May 9, 2019, 11:04:19 AM5/9/19
to go-cd
sorry should have mentioned, it gets replaced with ${env.GO_PIPELINE_COUNTER} and not the actual counter value 


On Thursday, May 9, 2019 at 3:50:16 PM UTC+1, Chris Flynn wrote:
It seems like that page is exactly what you need. Is it not working? Do you get an error message? What does the task and output look like?

On Thu, May 9, 2019 at 10:45 AM Martin c <martin...@kurtgeiger.com> wrote:
even doing something like
command: sh
arguments: -c
curl xyz $GO_PIPELINE_COUNTER

doesn't work

On Thursday, May 9, 2019 at 3:21:25 PM UTC+1, Martin c wrote:
Is it possible to use the Standard GoCD environment variables in a gocd pipeline? I'm trying to use it in a task e.g. $GO_PIPELINE_COUNTER or %GO_PIPELINE_COUNTER% but can't get it to work 

--
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...@googlegroups.com.

Chris Flynn

unread,
May 9, 2019, 11:06:13 AM5/9/19
to go...@googlegroups.com
That looks right to me, but I'm very new to GoCD and might be out of my league on this one. Did you try putting your arguments all on one line and not having a return in it? "-c curl xyz $GO_PIPELINE_COUNTER"

Did you test with an environment variable that you defined?

To unsubscribe from this group and stop receiving emails from it, send an email to go-cd+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/go-cd/8ada5a74-8c20-4fa2-8262-77b2e668d4bb%40googlegroups.com.

Chris Flynn

unread,
May 9, 2019, 11:12:04 AM5/9/19
to go...@googlegroups.com
Maybe try testing with a script too, instead of writing it out in the arguments box?

image.png
Reply all
Reply to author
Forward
0 new messages