Trying to add an existing pipeline to an environment using the new environment 
config API <https://api.go.cd/current/#environment-config>.

The method is PATCH.

I have tried this in PowerShell and in Curl and the error is the same.

412 PreCondition Failed. 

In addition, in Curl you see the following message: "Someone has modified 
the configuration for environment 'Commit'. Please update your copy of the 
config with the changes."

Looking at the source code 
<https://github.com/gocd/gocd/blob/832b21a7e563ad0893f94331886482921f1e908c/server/webapp/WEB-INF/rails.new/spec/controllers/api_v1/admin/environments_controller_spec.rb>
 
(and I am no expert in rails!) it *seems to me* that this message should 
only be returned if the method is PUT whereas this is PATCH.

Looking at the example <https://api.go.cd/current/#update-an-environment>, 
in an environment update call (which uses PUT) there is an additional 
header required it seems from the example curl request

If-Match: "26b227605daf6f2d7768c8edaf61b861"

There is no explanation of what this header is used for and why it needs to 
present and it is not there in the PATCH example.


Is this a bug or am I doing something silly?


My CURL request is:

 curl 'https://myserver.com/go/api/admin/environments/Commit'       -u 
'user:passwordI'       -H 'Accept: application/vnd.go.cd.v1+json'       -H 
'Content-Type: 
application/json'       -X PATCH       -d 
'{"pipelines":{"add":["pipeline_to_add"]}}' -verbose



The response is:

* Connected to myserver.com (10.129.0.9) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server key exchange (12):
* SSLv3, TLS handshake, Request CERT (13):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-SHA384
* Server certificate:
*        subject: blabla
*        start date: 2015-09-07 12:02:02 GMT
*        expire date: 2017-09-06 12:02:02 GMT
*        subjectAltName: myserver.com matched
*        issuer: blabla
*        SSL certificate verify ok.
* Server auth using Basic with user 'user'
> PATCH /go/api/admin/environments/Commit HTTP/1.1
> Authorization: Basic R29BZG1pbjpwViMlKUxNdkRQRTQjZzZJ
> User-Agent: curl/7.38.0
> Host: myserver.com
> Referer: rbose
> Accept: application/vnd.go.cd.v1+json
> Content-Type: application/json
> Content-Length: 60
>
* upload completely sent off: 60 out of 60 bytes
< HTTP/1.1 412 Precondition Failed
< Date: Wed, 28 Sep 2016 11:03:01 GMT
< Set-Cookie: JSESSIONID=ed06udyt7bsh1eym9kbppbhyg;Path=/go;Expires=Wed, 
12-Oct-2016 11:03:01 GMT;Secure;HttpOnly
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
< X-UA-Compatible: chrome=1
< Content-Type: application/vnd.go.cd.v1+json; charset=utf-8
< Cache-Control: no-cache
< X-Request-Id: aaa733e9-5986-4425-b04b-cad515dde4bc
< X-Runtime: 0.004000
< Transfer-Encoding: chunked
<
{
  "message": "Someone has modified the configuration for environment 
'Commit'. Please update your copy of the config with the changes."
}








-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to