azure-devops

Is an Azure DevOps build pipeline, is there a way to cancel one pipeline job from another job?

梦想与她 提交于 2020-12-29 04:59:38
问题 I have an Azure DevOps Build Pipeline which contains two Agent Jobs, which I'll call Job A and Job B. I want these jobs to run simultaneously, but if Job A fails, then I don't need Job B to run to completion. Is there any way to add a task to Job A which will cancel Job B (or, alternately, terminate the entire pipeline with a "Failed" status) if any of Job A's tasks failed? 回答1: Add a PowerShell task that cancel the pipeline when a task failed: steps: - powershell: | Write-Host "Cancel all

How to Enable Docker layer caching in Azure DevOps

岁酱吖の 提交于 2020-12-29 04:32:05
问题 I am running the below yaml script to build docker images and push into kubernetes cluster but at the same time I wanted to enable docker layer caching in the azure DevOps while building the yaml script.Could you please explain how to enable or how to add the task in azure devops to do this. Yaml: # Starter pipeline # Start with a minimal pipeline that you can customize to build and deploy your code. # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml trigger: - master

Is there a short 7-digit version of $(SourceVersion) in Azure Devops?

|▌冷眼眸甩不掉的悲伤 提交于 2020-12-25 09:22:25
问题 I am trying to set our build names to a format of... $(BuildDefinitionName)_$(versionMajor).$(versionMinor).$(versionPatch)+$(SourceBranchName).$(SourceVersion) e.g. OurBigLibraryCI_1.2.3+master.10bbc577 However I coudn't find any predefined variable holding the "short" (7-digit) version of the commit hash. $(SourceVersion) holds the full SHA-1 hash. How would one shorten that in yaml based pipeline? 回答1: How would one shorten that in yaml based pipeline? There is no out of box variable to

How to download a file in a branch from a Git repo using Azure DevOps REST Api?

旧时模样 提交于 2020-12-23 04:14:20
问题 For a file in the master branch I can use the following URL - http://tfsserver:8080/tfs/DefaultCollection/TFSProject/_apis/git/repositories/GitRepo/items?path=FilePath&api-version=4.1 But what if I need to download a file from the branch? P.S. I know perfectly well that I can clone a git repository. I need REST API specifically. EDIT 1 So, I tried the following code: $Url = "http://tfsserver:8080/tfs/DefaultCollection/code/_apis/git/repositories/xyz/itemsbatch?api-version=4.1" $Body = @" {

Azure DevOps Set Build number variable in a Build Task

荒凉一梦 提交于 2020-12-16 04:55:39
问题 In Azure DevOps, I created a Build. In that Build I created a ProjectBuildNumber Pipeline variable that is Settable at queue time. That variable is then used under Options -> Build number format to set my build number displayed in Azure. However, I am trying to make that ProjectBuildNumber variable settable in the code I am building/deploying. Is there a way I can have a Task in my Build to update that ProjectBuildNumber and update the Build number in Azure DevOps? 回答1: Is there a way I can

Azure DevOps Set Build number variable in a Build Task

て烟熏妆下的殇ゞ 提交于 2020-12-16 04:51:00
问题 In Azure DevOps, I created a Build. In that Build I created a ProjectBuildNumber Pipeline variable that is Settable at queue time. That variable is then used under Options -> Build number format to set my build number displayed in Azure. However, I am trying to make that ProjectBuildNumber variable settable in the code I am building/deploying. Is there a way I can have a Task in my Build to update that ProjectBuildNumber and update the Build number in Azure DevOps? 回答1: Is there a way I can

Project code is not being analyzed for sonarqube

空扰寡人 提交于 2020-12-16 04:48:48
问题 I have a repo in azure DevOps with only folder as test. Now, I have given the task structure in this way in azure DevOps. But I cannot see the code getting analyzed in sonarqube. The code tab shows blank. Could someone help me with where I am going wrong?? I do not want to give folder name in sources..I want whatever code I add in the branch to be analyzed. edit: Just realized this is happening only for feature short lived branch..My sonarqube version is 8.0 steps: task: SonarQubePrepare@4

Azure Artifacts gives 401 error on publishing a nuget package

只谈情不闲聊 提交于 2020-12-15 06:54:13
问题 Pushing a Nuget package to Azure Artifacts always gives 401 error. Note that the API key was just copied from Azure portal. What could be the issue? dotnet nuget push out/MonoTorrent.1.0.39.nupkg -s "myfeed" -k "myapikey" Output: Pushing MonoTorrent.1.0.39.nupkg to 'https://pkgs.dev.azure.com/myacct/c7fc868d-fd14-4f27-a36a-8ff9add6482c/_packaging/c2fe5b0f-251b-4017-9848-ed4b906d9fc0/nuget/v2/'... PUT https://pkgs.dev.azure.com/myacct/c7fc868d-fd14-4f27-a36a-8ff9add6482c/_packaging/c2fe5b0f

Pass file content as build argument in azure devops pipeline docker build task

浪尽此生 提交于 2020-12-15 06:26:12
问题 I want to pass my file content as build argument in docker build command using --build-arg. I am using following command in terminal and it is working fine docker build -t example --build-arg PRIVATE_KEY="$(cat /home/key)" . but when I am trying same thing in azure devops pipeline docker build task and passing --build-arg PRIVATE_KEY="$(cat /home/key)" in arguments box its taking the value as it is i.e, $(cat /home/key) and not executing the cat command. 回答1: I do not think it is the docker

Pass file content as build argument in azure devops pipeline docker build task

房东的猫 提交于 2020-12-15 06:25:09
问题 I want to pass my file content as build argument in docker build command using --build-arg. I am using following command in terminal and it is working fine docker build -t example --build-arg PRIVATE_KEY="$(cat /home/key)" . but when I am trying same thing in azure devops pipeline docker build task and passing --build-arg PRIVATE_KEY="$(cat /home/key)" in arguments box its taking the value as it is i.e, $(cat /home/key) and not executing the cat command. 回答1: I do not think it is the docker