Is there a REST API endpoint to get a collection of changes that are pending for a build in TeamCity?
We have the build set to manual and it is triggered outside TeamCity and would like to show a bullet point list of commits that'd be in that build.
In the user interface you can see this under the "Pending Changes (X)" tab.
I can't find any examples of doing this and the closest I've found is:
http://<server>/httpAuth/app/rest/changes/buildType:<build type id>
This seems to return the last change though.
Anyone done this before?
I just found a working solution thanks to this question. I'll show it here in case other people are looking for a full solution :
You need to know the buildTypeId of the build on which you want to get the pending changes. In this case lets say buildTypeId=bt85
1
http://<server>/httpAuth/app/rest/buildTypes/id:bt85/builds/
// Get the last build from the XML returned.
// Lets say last build id = 14000
2
http://<server>/httpAuth/app/rest/changes?build=id:14000
// The newest change returned is the one you need.
// Lets say newest change id = 15000
3
http://<server>/httpAuth/app/rest/changes?buildType=id:bt85&sinceChange=15000
// You're now looking at the pending changes list of the buildType bt85
My eventual solution in a work around kind of way is to:
Find the latest change ID from my database of builds outside of TeamCity (I guess you could query the TeamCity API to find the last successful build and pull it from there)
Then call:
http://<server>/httpAuth/app/rest/changes?buildId=id:<build id>&sinceChange=id:<last change id>
Then fetch each individual change from that list.
A bit of a workaround but I couldn't see anyway otherwise to get the list of pending changes.
Related
In my README.md I want to see automated tests results, e.g. something like:
[TestJob: failing] [TestJob Stats: 40 passed, 1 failed, 10 skipped, took 126 sec.]
There are existing workflows that can do this, e.g. https://github.com/marketplace/actions/dynamic-badges, BUT I'm on private enterprise repo, gist is disabled, and any content is not publicly visible, and requires token.
I figured I have two options.
Option1 - update README.md via e.g. bash script after execution, as part of the GitHub Action job.
Option2 - Find a way to customize the default badge.svg message.
Before I jump into spending time figuring out how to do option1, I want to ask - is there way to somehow relay / alternate the result text of the default badge.svg, currently it simply states "failing" passing" or "no status".
We have a need to reset VSTS counter. I do not see any way to do this through UI. There is a way to do it by directly invoking reset build counter REST API, but in order to do this, you need to know the counter id, which you should be able to find out by invoking get a definition REST API. Unfortunately, no matter what I do get a definition call does not return build definition counter.
What am I missing?
Scott Dallamura from Microsoft wrote this thread:
the counters feature was experimental and removed back in March of
this year. I'm not sure how it even got into the documentation, but
I'll make sure it gets cleaned up.
I also didn't success to get the counterId in an API call.
At workaround, you can reset the revision of the build number if you change the build definition name, you can just add/remove a character.
Instead of trying to reset the counter variable, you could create a new variable with a GUID prefix.
This solution creates duplicate counters which might not be ideal but this gives you the ability to revert back to the previous counter values, if necessary.
Please see the following YAML code snippet
variables:
...
#Change this Guid if you require a reset seed on the same value.
resetCounterGuid: 'efa9f3f5-57fb-4254-8a7a-06d5bb365173'
buildrevision: $[counter(format('{0}\\{1}',variables['resetCounterGuid'],variables['YOUR_DEFINED_VARIABLE']),0)]
...
I am trying to Get a RD and then call a PUT operation on the release object after updating some Variables in it.
The PUT operation is successful, the variables get updated in the RD, but all the other phases in the environment gets removed, except the 1st phase.
My RD has only one env I have not tried with more than one ENV for this operation.
Please suggest how can I update the RD through Rest call without loosing data.
URLs tried for GET:
The below URL don’t give Deployphases but PUT is successful with deleted phases
https://xxxxxxx.vsrm.visualstudio.com/xxxxxxx/_apis/Release/definitions/2016?api-version=4.1-preview.1
The below URL gives Deployphases but PUT fails with error that Deployphases should not be used rather Deploy step should be used.
https://xxxxxxx.vsrm.visualstudio.com/xxxxxxx/_apis/Release/definitions/2016
URLs tried for PUT:
behavior is same for both the URLs
https://xxxxxxxx.vsrm.visualstudio.com/xxxxxxx/_apis/Release/definitions?api-version=4.1-preview.1
https://xxxxxxxx.vsrm.visualstudio.com/xxxxxxx/_apis/Release/definitions/2016?api-version=4.1-preview.1
It's not a bug, you should use api-version=4.0-preview.3:
https://xxxx.vsrm.visualstudio.com/xxxx/_apis/Release/definitions?api-version=4.0-preview.3
I have a project running in Klocwork and after the build gets completed the Klocwork results will be generated. Every time I need to go to the Klocwork portal to get the results and look for the new issues or the total issues. Instead I need an API or script to get the total number of issues from the Klocwork results automatically when the build is successful.
Is there any way to achieve this? One way is to view the portal page source as html and get the result I need. However, I think there might be a better solution.
Can someone help me in achieving this?
Thanks in advance.
I answered a similar question over here. Below is an updated answer with links to the documentation for the most recent release, Klocwork 11.
Klocwork has a WebAPI which you can use to query this type of information from your favorite scripting language, or for example with curl. API documentation is also provided on your Klocwork server at http://klocwork_server_host:port/review/api, for example http://localhost:8080/review/api.
The query:
curl --data "action=search&user=my_account&project=my_project&query=build:build_1 status:Analyze state:New,Existing<oken=xxxx" http://localhost:8080/review/api
will return a list of all open (state New and Existing), non-cited (status Analyze) issues found in a build named build_1 of project my_project.
For a list of the keywords you can use in the query string with the search action, see Searching in Klocwork Review.
If you want just a summary of the number of defects instead of getting the whole list, you can use the report action:
curl --data "action=report&user=my_account&project=my_project&build:build_1&x=Category&y=Component&filterQuery=status:Analyze state:New,Existing<oken=xxxx" http://localhost:8080/review/api
which returns back a summary of the number of defects by checker category (taxonomy) and component. Sample output is below:
{"rows":[{"id":1,"name":"C and C++"},{"id":3,"name":"MISRA C"},{"id":4,"name":"MISRA C++"}],"columns":[{"id":5,"name":"System Model"}],"data":[[122],[354],[890]],"warnings":[]}
You can modify the x and y axis parameters to produce different breakdowns of the issues, for example by Severity and State instead:
curl --data "action=report&user=my_account&project=my_project&build:build_3&x=Severity&y=State&filterQuery=state:New,Existing,Fixed<oken=xxxx" http://localhost:8080/review/api
output:
{"rows":[{"id":1,"name":"Critical"},{"id":2,"name":"Error"},{"id":3,"name":"Warning"},{"id":4,"name":"Review"}],"columns":[{"id":-1,"name":"Existing"},{"id":-1,"name":"Fixed"},{"id":-1,"name":"New"}],"data":[[10,5,2],[20,6,1],[45,11,3],[1112,78,23]],"warnings":[]}
The WebAPI cookbook documentation has an example of using python with the report action and processing and formatting the response.
I'm currently trying to detect which drivers appear as "not working" in visual basic.
This unknown device is a good example of what I'm trying to grab (notice how it has the flag DN_HAS_PROBLEM).
I've tried using searches such as:
Dim searcher As New ManagementObjectSearcher( "root\CIMV2", "SELECT * FROM Win32_SystemDriver")
And running a loop in the searcher.Get() through this documentation
However, none of these seem to return what I am looking for.
Would anyone happen to know how I can get the DN_ statuses within Visual Basic?
Thanks!
The Win32_SystemDriver class documentation lists these Status properties:
OK
Error
Degraded
Unknown
Pred Fail
Starting
Stopping
Service
Stressed
NonRecover
No Contact
Lost Comm
...whereas DN_HAS_PROBLEM comes from the CM_Get_DevNode_Status function, or perhaps also from other system calls.
There may not be a way to get that specific code from the API you're using, but perhaps the existing Status properties will suffice for your needs if you don't need to know more specific failure reasons.
If you do need to know that specific status, you'll have to call other APIs, like the one I called out.