GoCD Server configuration as code

424 views
Skip to first unread message

Hagen Kuehn

unread,
Dec 8, 2016, 12:48:21 PM12/8/16
to go-cd
Hi All,

I wonder if it is possible to manage the base GoCD Server configuration as code?

I am aware of the pipeline as code feature, which is documented at https://docs.go.cd/current/advanced_usage/pipelines_as_code.html but I would also like to have the ability to manage all other configuration as code that gets stored in the cruise-config.xml file. I thought of using the API for this but it appears that it is not capable to set values for some aspects of the configuration.

For example it's possible to get a dump of the configuration with
curl 'https://ci.example.com/go/api/admin/config.xml' \
     
-u 'username:password'
but it's not possible upload a config.xml via the API.

All I can currently think off is a hacky approach, which is basically to pretend to be a browser and send the file to https://ci.example.com/go/admin/config_xml/edit

What we are after is the ability to manage the GoCD Server configuration in our Git repository, where we would conduct peer review and also have the ability to associated a particular configuration version with certain releases etc.

Thanks for your help,
Hagen

Aravind SV

unread,
Dec 8, 2016, 2:31:21 PM12/8/16
to go...@googlegroups.com
Hi Hagen,

Have you considered using tools such as gomatic or yagocd? This might be interesting too.

Cheers,
Aravind


--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hagen Kuehn

unread,
Dec 9, 2016, 7:36:55 AM12/9/16
to go...@googlegroups.com
Hi  Aravind,

Thank you for your suggestions, they are much appreciated.
For the use case I am after, the suggestion shown at https://groups.google.com/forum/#!msg/go-cd-dev/UjE9azB72Bc/RK-HtnPlwI8J seems to be sufficient. All I need is the ability to send the configuration xml back to the GoCD server without GUI. However I didn't manage to post the configuration file back to the server with curl.

This is the command I have been trying. It complains of 'xmlFile' parameter missing. Am I missing something?

  -u 'username:password' \
  -H "Content-Type:application/x-www-form-urlencoded" \
  -H "md5:a557ff49161e659c555363bcd50ab3bb" \
  -F "xmlFile=@gocdconfig.xml"


HTTP/1.1 100 Continue
HTTP/1.1 500 Required String parameter 'xmlFile' is not present
Date: Fri, 09 Dec 2016 12:22:26 GMT
Set-Cookie: JSESSIONID=16rhdvckghvsiubyi7fmg3fax;Path=/go;Expires=Fri, 23-Dec-2016 12:22:26 GMT;HttpOnly
Content-Type: text/html; charset=ISO-8859-1
Cache-Control: must-revalidate,no-cache,no-store
Content-Length: 1074

Thank you,
Hagen

Aravind SV

unread,
Dec 9, 2016, 10:37:12 AM12/9/16
to go...@googlegroups.com
Hi Hagen,

You should probably try something similar to:

curl -X POST http://localhost:8153/go/admin/restful/configuration/file/POST/xml \
  -d md5=baadf00ddeadbeefbaadf00ddeadbeef \
  --data-urlencode xml...@gocdconfig.xml


Cheers,
Aravind

Hagen Kuehn

unread,
Dec 9, 2016, 11:03:27 AM12/9/16
to go...@googlegroups.com
Hi Aravind,

This worked! Thanks for your help!
With this at hand I should be able to get a workflow in place to manage the GoCD server configuration in Git.

Kind Regards,
Hagen
Reply all
Reply to author
Forward
0 new messages