Is there anyway to delete a custom property? I am experimenting with adding and updating properties, however I want to perform some cleanup to remove or rename properties which are not correct. Adding through the UI is simple enough, however I have not had any success with creating or setting properties using the API. Nor can I update a custom defined property using the API if it already exists. Also, is it possible to set values on GO properties through the API, ie resetting the counter?
Per documentation:
#list http://[server]:8153/go/properties/[pipeline]/[pipelinecounter]/[stage]/[stagecounter]/[job]
#show http://[server]:8153/go/properties/[pipeline]/[pipelinecounter]/[stage]/[stagecounter]/[job]/[propertyname]
#create http://[server]:8153/go/properties/[pipeline]/[pipelinecounter]/[stage]/[job]/[propertyname]
Listing all properties:
http://<user>:<pass>@<goserver>:8153/go/properties[pipeline]/LATEST/[stage]/LATEST/[job] will retrieve the all properties correctly. NOTE: DOCUMENTATION DOES NOT INDICATE STAGECOUNTER IS REQUIRED, IT IS.
Getting a property:
http://<user>:<pass>@<goserver>:8153/go/properties[pipeline]/LATEST/[stage]/LATEST/[job]/cruise_pipeline_label will retrieve the cruise_pipeline_label correctly.
However, attempting to create or set a property results in 404 error.
Creating a property:
http://<user>:<pass>@<goserver>:8153/go/properties[pipeline]/LATEST/[stage]/[job]/[propertyname=value]
Code Snippet
#!c:\perl5.8.9\bin\perl
use LWP::Simple;
my $browser = LWP::UserAgent->new;
my $show = $goServer . '/go/properties/[pipeline]/LATEST/[stage]/LATEST/[job]';
my $create = $goServer . '/go/properties/[pipeline]/LATEST/[stage]/[job]';
my $authURL= "http://" . $user . ":" . $pass . "@";
my $getProp= $authURL . $show . "/$property";
my $request = get $getProp;
## $request return properly ##
#SET ALTERNATE 0
my $prop=qq!PRODUCT_version_label=xx.xx.xxx.xxx!;
my $createurl= $authURL . $create . "/" . $prop;
my $setresponse = $browser->post($createurl);
## setresponse returns 404 ##
#SET ALTERNATE 1
$createurl= $authURL . $create;
my $setresponse = $browser->post($createurl,[$prop],);
## setresponse returns 404 ##
#SET ALTERNATE 2
$prop=qq!PRODUCT_version_label!;
$createurl= $authURL . $create;
my $value=qq!xx.xx.xxx.xxx!;
my $setresponse = $browser->post($createurl,[$prop=>$value],);
## setresponse returns 404 ##
Comments
3 comments
Hi Lee,
As of now, you cannot update or delete an existing property. You can create new properties.
For example a curl post to create a new property called version with value 23 under Pipeline:dev,pipeline counter 6739,stage dev,stage counter 2 and job build will look like this.
curl -u username:password -d "value=23" http://go.thoughtworks.com:8153/go/properties/cruise/6739/dev/2/build/version
You have to post the value of the property using "value=23".
In your perl script, the $create url needs the stage counter (As you rightly pointed out), and I gues $prop needs to be set to "value"
Please look at the last example in this help page
-Santosh
Correction: The pipeline in the example above is cruise and not dev.
The problem is none of the options I tried actually worked. I will download cURL and try to see if I can get it to work.
Of course I want it to work without providing username and password, we do not want any of that logged.
Please sign in to leave a comment.