Wercker API v3 - /builds endpoint is empty - wercker

I have a public project on Wercker :
https://app.wercker.com/xurei/redux-api-react-switch/runs
I would like to list the builds via the API, but it outputs an empty array...
https://app.wercker.com/api/v3/applications/xurei/redux-api-react-switch/builds
What am I missing ?

So to get the last runs you have to use
https://app.wercker.com/api/v3/runs?applicationId=:your_application_id
which you can find out
https://app.wercker.com/api/v3/applications/:username/:application
In your case this link (https://app.wercker.com/api/v3/runs?applicationId=591dc80e1ff866010052b3d2) will give you the last 20 runs you can see the rest of the options in the documentation here

Related

SonarQube REST APIs : Read Metrics for individual projects

My question:
I am using SonarQube version 7.1 and trying to extract the metrics and quality gate related to individual projects.
What we have tried
We were using Python SonarQube API to extract these data before our company upgraded to version 7.1. "api/resources" web service Deprecated since sonarqube5.4, so we cannot use it anymore.
I have also tried using getting data using CURL command via Web API using
curl -i -H "Content-Type: application/json" -H "x-api-key:token" -X GET 'http://MY_HOST/api/measures/component?metricKeys=key&component=project_key'
We are able to get a json payload for individual metrics, but involves tedious task of creating the URL every single time.
But I wanted to know if there is a better/smarter way to access these "measures", be it any language or implementation.
You could do this:
Call the API api/metrics/search first to get a (json) list of all the metrics and then iterate over that list and create a comma separated string of all the metric keys.
For example something like this: ncloc,complexity,violations .. as mentioned in the parameters example value in the API documentation here.
Then you could just add this comma separated list to the url as a parameter something like: http://MY_HOST/api/measures/component?metricKeys=ncloc,complexity,violations&component=project_key
and call it once to get the response for all metrics.
Also, I haven't tried this, but as per the latest documentation, the parameter component is optional. So if you omit that, ideally you should get a response with metrics of all the projects.

Sonar API accessing Multiple Metrics

I am trying to use Sonar API for getting multiple metrices. When I am trying to get single Metric it is working fine but when giving a comma separated list it is returning blank response. E.g.
https://localhost/sonar/api/resources?format=json&metrics=tests [Works fine and returns response]
https://localhost/sonar/api/resources?format=json&metrics=ncloc [Works fine and returns response]
https://tools.publicis.sapient.com/sonar/api/resources?format=json&metrics=ncloc,tests [Returns blank reponse i.e [] json ]
Am I doing it wrong. I have used comma separated list previously and it used to work fine. But now I am not able to figure out what is the issue
My Sonar version is 5.6
api/resources is deprecated. Its metrics parameter does accept comma-separated values (test it in a browser first, and careful with any reverse-proxy that may rewrite URLs), but you're better off using the most modern and up-to-date API: api/measures (documentation embedded in your SonarQube server), which also supports multiple values for metricKeys parameter.
for me api/resources works fine with multiples metrics, i call like that
https://localhost/sonar/api/resources?resource=[keyproject]&metrics=coverage,blocker_violations,critical_violations,sqale_debt_ratio

Getting actions of changed files from TeamCity's REST Api

I am using TeamCity's REST api to get the list of changed files for a specific change.
I do it like this:
http://teamcityserver:8111/httpAuth/app/rest/changes/id:
In the result, I am getting a bunch of "file" xml nodes. However, for each file, I would like to know the action done on it (was this file added? removed? edited?) and this information is not present in the file nodes.
Is there a way I can get this information from the api?
(I am using TeamCity 9, if that's relevant)
I just got a response from TeamCity support saying that it's not possible:
"Unfortunately it is not possible to get the file action via REST API".

Using TeamCity build number in Buildmaster

Is it possible to grab the build number from TeamCity and use that as a build number in BuildMaster?
This could be done by triggering the BuildMaster API's Builds_CreateBuild method from TeamCity which accepts a numeric build number. It should be fairly straightforward to make a GET request to the BuildMaster JSON API from TeamCity, see this question for a simple way to do so: TeamCity Call Url Build Step
In order to create a new build including the build number you need to firstly enable the api under settings. There is no 'enable' button as such, you just need to provide an arbitrary key for the api authentication (any literal will do, but presumably make it complex for best security!).
The JSON syntax for the creating a build is as follows:
http://buildmaster-server/api/json/Builds_CreateBuild?API_Key=abcde12345&Build_Number=123&Release_Number=0.0
This will actually create a new build on your build master server. This can then be triggered via Team City using Powershell with the powershell script inline such as:
Invoke-WebRequest "http://buildmaster-server/api/json/Builds_CreateBuild?API_Key=abcde12345&Build_Number=%build.number%&Release_Number=0.0&Application_Id=2" -UseBasicParsing
You can add further variables and call hundreds of BuildMaster API's using the above method. Full API documentation can be found here: http://inedo.com/support/documentation/buildmaster/reference/api-methods

Team City Rest API - Getting running builds

I'm trying to use the Team City rest api to get a list of the currently executing builds. It seems like it is only returning builds on the default branch and I would like to get the builds on all branches. This is the api call I'm using:
/teamcity/guestAuth/app/rest/builds?locator=running:true&branch:(default:any)
found the issue the url should be:
/teamcity/guestAuth/app/rest/builds?locator=running:true,branch:(default:any)

Resources