Pipelines
11 TopicsSetting up Code Coverage data in Azure DevOps Pipeline, C# .NET 9
Hello everyone, I would like some assistance with my Azure DevOps pipeline. I am trying to set up Tasks in my Azure DevOps pipeline to collect Code Coverage results, after running UTs using the VsTest Task, to then have a Powershell Task in the Pipeline write to a SQL db the contents of those metrics. The main issue I am encountering is actually finding the published results after the UTs successfully run. I have set up Tasks to publish the results, then find them & then insert, but the publish doesn't seem to actually publish to the directory I specify, or if it does publish, I cannot see where to. Here are the Tasks I currently have set-up. Task to run UTs: steps: - task: VSTest@2 displayName: 'VsTest - testAssemblies' inputs: testAssemblyVer2: | **\$(BuildConfiguration)\*\*test*.dll !**\obj\** runSettingsFile: '$/B3API/Main/B3API.Tests/codecoverage.runsettings' runInParallel: true runTestsInIsolation: false codeCoverageEnabled: true platform: '$(BuildPlatform)' configuration: '$(BuildConfiguration)' failOnMinTestsNotRun: true codecoverage.runsettings file: <?xml version="1.0" encoding="utf-8"?> <RunSettings> <DataCollectionRunSettings> <DataCollectors> <DataCollector friendlyName="Code Coverage"> <Configuration> <Format>cobertura</Format> </Configuration> </DataCollector> </DataCollectors> </DataCollectionRunSettings> </RunSettings> Task to publish results: steps: - task: PublishCodeCoverageResults@2 displayName: 'Publish code coverage results' inputs: summaryFileLocation: '$(System.DefaultWorkingDirectory)/**/coverage.cobertura.xml' pathToSources: '$(System.DefaultWorkingDirectory)/**/coverage' Task to find published file & store into variable: steps: - powershell: | $coverageFile = "$(System.DefaultWorkingDirectory)/**/coverage.cobertura.xml" [xml]$coverageData = Get-Content $coverageFile $coveragePercentage = $coverageData.coverage.@line-rate # Store the coverage data in a variable Write-Host "##vso[task.setvariable variable=coveragePercentage]$coveragePercentage" displayName: 'Store Coverage in variable' The main issue it the Task to publish, it does not publish the results, I think it is due to not finding them in the first place. Thank you for taking the time to read my post, any help would be greatly appreciated, thanks!92Views0likes3CommentsHow to delete pipeline tags with special characters?
I want to delete specific tags attached to Azure pipeline builds, for example "hello: world". I've come to the conclusion that the ADO REST API endpoint for handling Tag deletions cannot parse special characters in the URL's slug i.e. colons and whitespaces. According to the docs here, the tag should be specified in the URL slug, followed by query string parameters if applicable. I tried the following: 1. If I insert the tag directly into the URL it will look like this: https://dev.azure.com/organisation/project/_apis/build/builds/1234567/tags/hello: world?api-version=7.1 This returns: "Response status code does not indicate success: 400 (Bad Request)." 2. But if I encode my slug using `[System.Web.HttpUtility]::UrlEncode($tag)`, the URL looks like this: https://dev.azure.com/organisation/project/_apis/build/builds/1234567/tags/hello%3a+world?api-version=7.1 This returns "Response status code does not indicate success: 404 (Not Found)." So it seems the encoding might have worked, although it appears to be searching for a tag without decoding the URL first? Does anyone know if there is a way for deleting tags with special characters? I have over 1600+ tags that need to be deleted so manually doing this through the UI would not be a viable option. EDIT: I just realised the documentation has a small note saying: This API will not work for tags with special characters. To remove tags with special characters, use the PATCH method instead (in 6.0+) Tried the PATCH method instead of DELETE and still not working. And there's no examples provided in the docs.59Views0likes2CommentsAzure DevOps git tag release pipeline
I'm wanting to get an Azure DevOps Pipeline (Classic) to run on a schedule against a Git Tag. This tag is set by a CD pipeline to mark when it has been deployed in the live environment. The scenario is that a "safe" release can be re-released on a regular schedule to ensure that it still matches what is expected (it's an Azure ARM release, and I want to tidy up any unauthorised changes made by lazy engineers). I cannot though find a way to achieve this. While you can filter on tags from builds in a release pipeline, that's not Git tags, but things manually set in ADO. I have tried using a build pipeline first (don't actually need one for this, but I can live with it) and using a branch filter to refs/tags/mytag, but it never seems to run. Can anybody help out here?1.2KViews0likes2CommentsMirrors boards from one project to another
Hello, We have 2 projects under same org in our ADO instance. Project A holds pipelines and repos whereas the other Project B has the boards and work items. We would like to mirror the project B boards in project A which has pipelines and repos. Kindly suggest here. Thank you, Abhinav.905Views0likes0CommentsGrant "Pipeline Resources Use and Manage" for System.AccessToken
I have an Azure DevOps pipeline where I am generating an Azure DevOps environment, then I trigger new pipelines that target these environment. Before I do this, however, I am allowing pipelines to be used in this environment with the following script: $EnvironmentId = (terraform output -raw devops_environment_id) $base64EncodedPat = [Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("-:$(System.AccessToken)")) $apiHeaders = @{ Authorization = "Basic $base64EncodedPat"} Write-Host "Getting environments for ID $EnvironmentId" # Get all agent pools, and filter by naming convention on name of "environment-$EnvironmentId" $deploymentTargetsRaw = (Invoke-WebRequest ` -Headers $apiHeaders ` -Uri "https://dev.azure.com/MyOrganisation/_apis/distributedtask/pools?poolType=deployment&api-version=7.1-preview.1").Content $deploymentTargets = $deploymentTargetsRaw | ConvertFrom-Json -Depth 100 $resources = @( @{ resource = @{ type = "environment" id = $EnvironmentId } allPipelines = @{ authorized = $true } } ) $deploymentTargets.value ` | Where-Object { $_.name.StartsWith("environment-$EnvironmentId") } ` | ForEach-Object { Write-Host "Matched agent ID $($_.id) because it has name $($_.name)" $resources += @{ resource = @{ type = "agentpool" id = $_.id } allPipelines = @{ authorized = $true } } } #Now disable pipeline granting permissions on all agentpools and the environment $result = Invoke-WebRequest ` -Headers $apiHeaders ` -Uri "https://dev.azure.com/MyOrganisation/MyProject/_apis/pipelines/pipelinepermissions?api-version=7.1-preview.1" ` -Body (ConvertTo-Json $resources) ` -Method Patch ` -ContentType "application/json" Write-Host "Status = $($result.StatusCode) granting resources for $($resources.Length) resources in environment $EnvironmentId" Write-Host "response from API call`r`n$($result.Content)" This has, however, stopped working because Azure DevOps have released a new PAT scope Pipeline Resources Use and Manage, which the $(System.AccessToken) does not have. Does anyone know if it is possible to grant this scope to the $(System.AccessToken)?2.4KViews2likes2CommentsTrigger Azure pipeline from multiple repositories
Hello. I am trying to create a simple pipeline that runs tests. I wanna trigger my pipeline from 2 repositories (I used this doc https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#triggers). The first repository contains ‘azure-pipelines.yml’, in which I specified triggers from both repos: resources: repositories: - repository: todo-app-server type: github endpoint: max_pat name: maximkulakivsky/todo-app-server trigger: - master trigger: - master ... When I make a commit to the first repository everything is working and the pipeline is triggered. But when I make a commit to the second repo nothing is happening. I tried changing my Oauth connection to Github PAT (I used this doc https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml), but that didn’t help. Please, help me.9.1KViews0likes2CommentsGitHub App authentication for Azure Pipelines causes webhooks to dissapear
Greetings, we are using GitHub as the code repository service together with Azure DevOps Pipelines for CI/CD. All the pipelines need to have their triggers authenticated to GitHub in order for the pipelines to trigger Authentication works either with personal OAuth Service Connections or via the Azure Pipelines App for GitHub The recommended way is using the Pipelines App The problem: when I authenticate the pipeline trigger via the GitHub Azure Pipelines App, the webhooks from the repository which the pipeline is pointing to dissapear and the automatic triggering stops working! To make the issue even more ridiculous - we have 5 pipelines but only with 4 of them this happens! One is working completely fine with with the recommended GitHub App authentication. What I tried: Recreating service connections in Azure DevOps Reinstalling the Azure Pipelines GitHub App Recreating the pipelines Nothing worked, I am forced to use OAuth which is always throwing a warning to switch to app authentication because it's better performing and more reliable. Quite ridiculous to recommend a certain way of doing things, then making it work less reliable than the not-recommended way. Anyone has any ideas? Thanks in advance.2KViews0likes0CommentsSudden errors with pipelines and artefacts: Can't download artifacts from other pipelines
Hi, since today I'm experiencing issues with the DownloadArtifactPipeline suddenly. What we do is basically downloading an artifact from a different pipeline. ##[error]No builds currently exist in the pipeline definition supplied. This is strange because it worked flawlessly before, has something changed with this task? Or have someone experienced the same issue before - task: DownloadPipelineArtifact@2 displayName: 'Download Pipeline Artifact' inputs: source: 'specific' project: 'xxxx' pipeline: '2303' buildVersionToDownload: 'latestFromBranch' branchName: 'refs/heads/main' path: '$(Pipeline.Workspace)/stages'3.4KViews1like0Comments