Changing the timer of a pipeline with GoCD API

26 views
Skip to first unread message

Tobias Petrén

unread,
Mar 18, 2020, 6:41:24 AM3/18/20
to go-cd
Hi.

I want to edit the timer with GoCD API on a pipeline that has already been created. This is what the structure of the timer looks like according to GoCD API.

timer.PNG


I follow this structure for my API call and try to edit the pipelines timer according to the call below.


curl -k "https://localhost:8154/go/api/admin/pipelines/pipeline_name" -H "Accept: application/vnd.go.cd.v10+json" -H "Content-Type: application/json" -H "If-Match: "ca0f7e7a6f033093dbefadaa08f8f4f2"" -X PUT -d "{"group": "pipeline_group_name", "name": "pipeline_name", "timer": {"spec": "0 0 22 ? * MON-FRI", "only_on_changes": true}}"


When I execute this I get the error below. It seems like it does not accept the structure that is on the "spec" object. How can I fix this?



error.png


Thanks!


/Tobias





kritik...@thoughtworks.com

unread,
Mar 18, 2020, 6:45:48 AM3/18/20
to go-cd
Hello Tobias,

The update pipeline config API (https://api.gocd.org/current/#edit-pipeline-config) is a PUT call not a PATCH. Hence, you need to send the complete pipeline config object with the modified timer object for the API to work.

Thanks
Kritika

Ketan Padegaonkar

unread,
Mar 18, 2020, 6:49:12 AM3/18/20
to go...@googlegroups.com
Additionally: You're not quoting/escaping your JSON properly. The following are valid, what you have is not:

curl ... -d '{"foo": "bar"}'

or

curl ... -d "{\"foo\": \"bar\"}"

- Ketan



--
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/a3618707-cc3c-4e8a-ba70-21094b6ef357%40googlegroups.com.

Ketan Padegaonkar

unread,
Mar 18, 2020, 6:49:23 AM3/18/20
to go...@googlegroups.com
Additionally: you're not quoting the JSON properly.
- Ketan



--
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.

Tobias Petrén

unread,
Mar 18, 2020, 7:08:43 AM3/18/20
to go-cd
Ok, thanks for your quick responses. I will try this approach instead then!
To unsubscribe from this group and stop receiving emails from it, send an email to go...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages