Disallowing triggering old builds

11 views
Skip to first unread message

Ilari Mäkimattila

unread,
Sep 12, 2019, 7:14:55 AM9/12/19
to go-cd
Hello,

I'm looking for a way to prevent anyone from manually running a pipeline that is not the newest version, for example by going to the pipeline history page and clicking the rerun button. The reason for this is that we're using Go to run infrastructure changes and running an old configuration could lead to a broken state that is hard to resolve.

I've read through the manual and I didn't anything relevant and so I believe this feature doesn't exist but I would be happy with a workaround of making the build fail if it detects that it's not the latest one. I'd really appreciate any hints on how to achieve this.

Thank you!

Best,
Ilari

Aravind SV

unread,
Sep 12, 2019, 10:44:50 AM9/12/19
to go...@googlegroups.com
Hello Ilari,
I think one way would be to use the pipeline history API to verify that the instance you're on right now (based on the GO_PIPELINE_COUNTER environment variable) is the latest one. And, having the script which checks this be the first task in the job.

Another, slightly easier approach might be to fail the script if the GO_STAGE_COUNTER environment variable is not 1. On a re-run, it will be a number higher than 1.

Pipeline history API: https://api.gocd.org/current/#get-pipeline-history

Environment variables: https://docs.gocd.org/current/faq/dev_use_current_revision_in_build.html#standard-gocd-environment-variables

Cheers,
Aravind

Ilari Mäkimattila

unread,
Sep 12, 2019, 11:49:00 AM9/12/19
to Aravind SV, go...@googlegroups.com
--
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/20190912144445.ahf3m73vaumimqbw%40arvindsv.com.

Thanks Aravind.

I figured as much. Looking at the GO_STAGE_COUNTER is not an option because rerunning the latest pipeline instance should stay possible.

Does the API require authentication when called from the agent?

Best,
Ilari
Reply all
Reply to author
Forward
0 new messages