I have a YAML Build Definition that uses multiple repos.
When looking at the Build Results, there is a "Sources" Card that lists the Repos and the commit ID that was used for this particular build.
I tried looking through all the api documentation for this info, but I can't seem to find it easily. I took a look at the Get Build call, but that just gives the Main Repo used.
Does anyone know the API well enough to point me to the api call to access that set of Data that contains the repos/resources and their commit ids ?
Thanks!
You can use the following REST API:
GET https://dev.azure.com/{Organization}/{Project}/_build/results?buildId={Build ID}&__rt=fps&__ver=2
Its response body is quite massive, the information about multiple repositories is in:
fps -> dataProviders -> data -> ms.vss-build-web.run-details-data-provider -> repositoryResources
It shows all source repositories including their names, ids, versions, and so on.
This REST API is not documented and I get it from Developer Tools. Most of the information contained in it is web page information.
It looks that this is not available over REST API (yet). However, this is really strange, because if you hit get build endpoint:
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/826?api-version=6.0-preview.6&expand=all
in link section you will find sourceVersionDisplayUri
"_links": {
"self": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/Builds/826"
},
"web": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_build/results?buildId=826"
},
"sourceVersionDisplayUri": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/826/sources"
},
"timeline": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/builds/826/Timeline"
},
"badge": {
"href": "https://dev.azure.com/thecodemanual/4fa6b279-3db9-4cb0-aab8-e06c2ad550b2/_apis/build/status/43"
}
},
but the URL redirects you to commit which actually trigerred a build.
It still possible to get commits and repos from the logs
https://dev.azure.com/{{organization}}/{{project}}/_apis/build/builds/826/logs/6?api-version=6.0-preview.2
But for that you need to get trough them and parse responses:
2020-05-08T11:13:04.3354990Z Syncing repository: kmadof/devops-templates (github)
.
.
.
.
2020-05-08T11:13:03.3810662Z ##[command]git checkout --progress --force 24602dc40710a53502d306d1d41d3bca3c9a9b80
2020-05-08T11:13:03.3816465Z Note: switching to '24602dc40710a53502d306d1d41d3bca3c9a9b80'.
2020-05-08T11:13:05.1455197Z ##[command]git checkout --progress --force 0d79e869239bbf0087492ac2cda3a59e9ef11a39
2020-05-08T11:13:05.1458382Z Note: switching to '0d79e869239bbf0087492ac2cda3a59e9ef11a39'.
Related
I have installed the PRLint Github app (https://github.com/ewolfe/prlint) on my GitHub repository
As required, I have some PRLint configuration in .github/prlint.json
prlint.json
{
"title": [
{
"pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test):\\s",
"message": "PR title needs to be prefixed with a topic"
}
],}
However when I'm creating any PR, this is not triggering the PRLint to check if the PR is meeting the requirements or not
Under the repository "branch protection rules" I opted to pass all status checks to pass.
Please note I tried to look for PRLint in search box but nothing was found.
Well I found an alternate app for it that served the purpose
PRLint Reloaded
https://github.com/maor-rosenfeld/prlint-reloaded
My ~/.github/prlint.json
{
"title": [
{
"pattern": "^(build|ci|docs|feat|fix|perf|refactor|style|test):\\s",
"message": "PR title needs to be prefixed with a topic"
}
]
}
Repository Settings
That's it! :)
I am trying to make hundreds of environments on Azure Devops using a PowerShell script and REST API. I need to include approvers on some of it.
I can already create those environments, I just need to add/update the approvers for it.
How can I do that? I can't seem to find anything on the documentation
To add /update the approvers for environments, you can use the following Rest API:
Add approvers for environment:
Rest API:
Post https://dev.azure.com/Orgname/Project/_apis/pipelines/checks/configurations?api-version=api-version=7.1-preview.1
Request Body:
{
"type":{
"id":"8C6F20A7-A545-4486-9777-F762FAFE0D4D",
"name":"Approval"
},
"settings":{
"approvers":[{"displayName":"{UserName}","id":"{UserID}"}],
"executionOrder":1,
"blockedApprovers":[],
"minRequiredApprovers":0,
"requesterCannotBeApprover":false
},
"resource":
{
"type":"environment",
"id":"{EnvironmentID}",
"name":"{EnvironmentName}"
}
}
Update approvers for environment:
Rest API:
PATCH https://dev.azure.com/{organization}/{project}/_apis/pipelines/checks/configurations/{Configurationid}?api-version=7.1-preview.1
Request Body:
{
"type":{
"id":"8C6F20A7-A545-4486-9777-F762FAFE0D4D",
"name":"Approval"
},
"settings":{
"approvers":[
{
"displayName":"{Username}",
"id":"{UserID}"
},
{
"displayName":"{Username}",
"id":"{UserID}"
}
],
"executionOrder":1,
"blockedApprovers":[],
"minRequiredApprovers":0,
"requesterCannotBeApprover":false
},
"resource":
{
"type":"environment",
"id":"{EnvironmentID}",
"name":"{EnvironmentName}"
}
}
For the configuartionID, you can get the ID in the following Rest API: Check Configurations - List
Since the requirement has no official sample, you can check the NetWork trace for more detailed info.
For example: Manually add/update the approvers and Check network tab in Browser Developer tool.
Have a look at the Approvals and Checks API
We need a way to access data through an automated way (either Rest API or some SDK) that is contained within the Retrospective Azure Dev Ops extension. Currently, there is an option to export CSV but the process is manual and limited to each Retrospective. Any ideas/thoughts?
You can try like as the following steps:
Run the API to get the information of project teams in a project.
Request URL
POST https://dev.azure.com/{organization_Name}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1
Request Body
{
"contributionIds": ["ms.vss-admin-web.org-admin-groups-data-provider"],
"dataProviderContext": {
"properties": {
"teamsFlag": true,
"sourcePage": {
"url": "https://dev.azure.com/{organization_Name}/{project_Name}/_settings/teams",
"routeId": "ms.vss-admin-web.project-admin-hub-route",
"routeValues": {
"project": "{project_Name}",
"adminPivot": "teams",
"controller": "ContributedPage",
"action": "Execute",
"serviceHost": "{organization_Id} ({organization_Name})"
}
}
}
}
}
Run the API to list the retrospectives for a specified project team in the project.
GET https://extmgmt.dev.azure.com/{organization_Name}/_apis/ExtensionManagement/InstalledExtensions/ms-devlabs/team-retrospectives/Data/Scopes/Default/Current/Collections/{projectTeam_identityId}/Documents?api-version=3.1-preview.1
Run the API to get more details about a specified retrospective.
GET https://extmgmt.dev.azure.com/{organization_Name}/_apis/ExtensionManagement/InstalledExtensions/ms-devlabs/team-retrospectives/Data/Scopes/Default/Current/Collections/{retrospective_Id}?api-version=3.1-preview.1
However, we have not any available interface (API or CLI) to Export CSV content.
I am trying to integrate Azure App insights service into the service fabric app for logging and instrumentation. I am running fabric code on my local VM. I exactly followed the document here [scenario 2]. Other resources on learn.microsoft.com also seem to indicate the same steps. [ex: https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-diagnostics-event-aggregation-eventflow
For some reason, I don’t see any event entries in App insights. No errors in code when I do this:
ServiceEventSource.Current.ProcessedCountMetric("synced",sw.ElapsedMilliseconds, crc.DataTable.Rows.Count);
eventflowconfig.json contents
{
"inputs": [
{
"type": "EventSource",
"sources": [
{ "providerName": "Microsoft-ServiceFabric-Services" },
{ "providerName": "Microsoft-ServiceFabric-Actors" },
{ "providerName": "mystatefulservice" }
]
}
],
"filters": [
{
"type": "drop",
"include": "Level == Verbose"
}
],
"outputs": [
{
"type": "ApplicationInsights",
// (replace the following value with your AI resource's instrumentation key)
"instrumentationKey": "XXXXXXXXXXXXXXXXXXXXXX",
"filters": [
{
"type": "metadata",
"metadata": "metric",
"include": "ProviderName == mystatefulservice && EventName == ProcessedCountMetric",
"operationProperty": "operation",
"elapsedMilliSecondsProperty": "elapsedMilliSeconds",
"recordCountProperty": "recordCount"
}
]
}
],
"schemaVersion": "2016-08-11"
}
In ServiceEventSource.cs
[Event(ProcessedCountMetricEventId, Level = EventLevel.Informational)]
public void ProcessedCountMetric(string operation, long elapsedMilliSeconds, int recordCount)
{
if (IsEnabled())
WriteEvent(ProcessedCountMetricEventId, operation, elapsedMilliSeconds, recordCount);
}
EDIT
Adding diagnostics pipeline code from "Program.cs in fabric stateful service
using (var diagnosticsPipeline =
ServiceFabricDiagnosticPipelineFactory.CreatePipeline($"{ServiceFabricGlobalConstants.AppName}-mystatefulservice-DiagnosticsPipeline")
)
{
ServiceRuntime.RegisterServiceAsync("mystatefulserviceType",
context => new mystatefulservice(context)).GetAwaiter().GetResult();
ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id,
typeof(mystatefulservice).Name);
// Prevents this host process from terminating so services keep running.
Thread.Sleep(Timeout.Infinite);
}
Event Source is a tricky technology, I have been working with it for a while and always have problems. The configuration looks good, It is very hard to investigate without access to the environments, so I will make my suggestions.
There are a few catches you must be aware of:
If you are listening etw events from a different process, your process must be running with a user with permissions on 'Performance Log Users. Check which identity your service is running on and if it is part of performance log users, who has permissions to create event sessions to listen for these events.
Ensure the events are being emitted correctly and you can listen to them from Diagnostics Events Window, if it is not showing there, there is a problem in the provider.
For testing purposes, comment out the line if (IsEnabled()). it is an internal check to validate if your events should be emitted. I had situations where it is always false and skip the emit of events, probably it cache the results for a while, the docs are not clear how it should work.
Whenever possible, use the EventSource from the nuget package instead of the framework one, the framework version is full of bugs and lack fixes found in the nuget version.
Application Insights are not RealTime, sometimes it might take a few minutes to process your events, I would recommend to output the events to a console or file and check if it is listening correctly, afterwards, enable the AppInsights.
The link you provide is quite outdated and there's actually a much better way to log application error and exception info to Application insights. For example, the above won't help with tracking the call hierarchy of an incoming request between multiple services.
Have a look at the Microsoft App Insights Service Fabric nuget packages. It works great for:
Sending error and exception info
Populating the application map with all your services and their dependencies (including database)
Reporting on app performance metrics,
Tracing service call dependencies end-to-end,
Integrating with native as well as non-native SF applications
I've set up a satis repository on github to share some company internal packages across projects.
Now when I try to "depend" on the new repository, I tried this:
"repositories": [ {
"type": "composer",
"url": "https://raw.githubusercontent.com/[organisation]/satis/master/web/packages.json?token=[token-copied-from-url]"
} ]
and it works far enough that composer finds package.json, however, then it fails with:
[Composer\Downloader\TransportException]
The "https://raw.githubusercontent.com/[organization]/satis/master/web/packages.json?token=[token-copied-from-url]/include/all$[some-json-file].json" file could not be downloaded (HTTP/1.1 404 Not Found)
which isn't surprising as the ?token part appears to generate an invalid url.
I can work around this by manually moving the contents of the included file into packages.json directly, but this is less than ideal, especially if satis decides to generate multiple files.
Another problem I assume this will cause is that I don't know much about the validity of the token. Perhaps it doesn't have a long lifetime and then satis will need to be regenerated regularly.
Is there a way I can get away with hosting my satis repo as "just" a github repo?
You can store your static Satis repository in a private GitHub repo, and then use GitHub's raw.githubusercontent.com domain to serve it over HTTPS. The slightly hacky part is ensuring that composer properly authenticates against the GitHub repo.
Push Satis repository to GitHub
Generate your Satis repository and push it to your private GitHub repo, lets's say https://github.com/your-org/your-satis-repo inside the output/ directory.
Prepare your projects' composer.json files
In your projects' composer.json files, add your Satis repo to the "repositories" section:
{
"type": "composer",
"url": "https://raw.githubusercontent.com/your-org/your-satis-repo/master/output"
}
Set up HTTP basic authentication
Finally, to make composer authenticate via HTTP basic auth against raw.githubusercontent.com you will need do add a new entry to the "http-basic" section in your local composer's auth.json:
{
"http-basic": {
"raw.githubusercontent.com": {
"username": "GITHUB_USERNAME",
"password": "GITHUB_TOKEN"
}
}
}
Caveats
We've found that raw.githubusercontent.com is cached, so it can take a few minutes before changes to your Satis repository are visible.
Initial testing suggests it can be done.
I think you need to remove packages.json from your repository URL and I suspect the ?token parameter. In theory you can pass the token via a header:
https://developer.github.com/v3/#authentication
I have not tested this however.
You can see a working test without authentication here:
https://github.com/markchalloner/satishostcomposer
https://github.com/markchalloner/satishost
To try it out:
git clone git#github.com:markchalloner/satishostcomposer.git
cd satishostcomposer
composer install
Should install vendor/markchalloner/satishostdemo
Example satis.json:
{
"name": "Satis Host",
"homepage": "https://raw.githubusercontent.com/markchalloner/satishost/master/web/",
"archive": {
"directory": "dist",
"format": "tar",
"prefix-url": "https://raw.githubusercontent.com/markchalloner/satishost/master/web/",
"skip-dev": true
},
"repositories": [
{
"_comment": "Demo packages",
"type": "package",
"package": {
"name": "markchalloner/satishostdemo",
"version": "0.1.0",
"dist": {
"type": "zip",
"url": "dist/demo.zip"
}
}
}
],
"require-all": true
}
Example composer.json (in your project):
{
"repositories": [
{
"type": "composer",
"url": "https://raw.githubusercontent.com/markchalloner/satishost/master/web",
"options": {
"http": {
"header": [
"API-TOKEN: YOUR-API-TOKEN"
]
}
}
}
],
"require": {
"markchalloner/satishostdemo": "0.1.0"
},
"minimum-stability": "dev"
}
Thanks