标签: azure-pipelines

在releases/*中创建新分支时触发Azure管道

我们希望采用基于主干的开发分支策略,如此处所述 作为我们解决方案的一部分,我们希望每当从主干(主干)创建新的发布分支时触发Azure管道:例如releases/R.1

我们当前的管道 yaml 如下所示:

trigger:
 branches:
  include:
  - releases/*

...
Run Code Online (Sandbox Code Playgroud)

不幸的是,它在创建分支时不会触发。我怀疑当我们对发布分支进行更改时它会触发,但根据基于主干的开发,我们计划仅合并来自 master 的精选错误修复/修补程序。有没有办法在分支创建时触发管道?

azure-devops azure-pipelines

2
推荐指数
1
解决办法
3949
查看次数

使用 npm 任务与在 Azure 管道中使用脚本有什么区别?

在执行 npm 安装时,我正在努力找出 Azure 管道的以下两个片段之间的差异。

片段 1(使用任务):

- task: Npm@1
  inputs:
    command: 'install'
Run Code Online (Sandbox Code Playgroud)

片段 2(使用脚本):

- script: npm install
Run Code Online (Sandbox Code Playgroud)

我唯一的猜测是一个比另一个性能更好?另外,是否推荐一种方法而不是另一种方法?

azure-pipelines azure-pipelines-yaml

2
推荐指数
1
解决办法
2248
查看次数

Azure Devops - 无法构建从 vs2017-win2016 到 windows-latest 的管道代理

我的管道运行后,它给了我以下警告。

##[warning]The windows-2016 environment will be deprecated on November 15, 2021, 
and removed on March 15, 2022. Migrate to windows-latest instead. 
For more details see https://github.com/actions/virtual-environments/issues/4312
Run Code Online (Sandbox Code Playgroud)

看到该警告后,我尝试将 Agent Sepecification 从 vs2017-win2016 更改为 windows-latest。但代理规范下拉列表中没有 Windows 最新选项。

代理规范下拉列表

所以,我认为我可以从管道 yaml 文件更改它。但我无法在 yaml 编辑器上编辑管道。因为编辑页面仅以 UI 编辑器格式显示,如下图所示。

任务助手界面

我的问题是,如何打开 yaml 文件格式的管道编辑页面?如果不允许这样做,我如何为代理规范选择 windows-latest 选项?

yaml azure-devops azure-pipelines

2
推荐指数
1
解决办法
4763
查看次数

Azure DevOps 管道在 .net 6 中恢复 AutoMapper NuGet 包时出现问题

当我的管道运行时,我收到以下错误消息:

包 AutoMapper.Extensions.Microsoft.DependencyInjection 8.1.1 与 net60 (.NETFramework,版本 = v6.0) 不兼容。软件包 AutoMapper.Extensions.Microsoft.DependencyInjection 8.1.1 支持: netstandard2.0 (.NETStandard,Version=v2.0) 一个或多个软件包与 .NETFramework,Version=v6.0 不兼容。)

我可以在这里做些什么,还是需要等待 AutoMapper 团队更新?

c# automapper azure-devops azure-pipelines .net-6.0

2
推荐指数
1
解决办法
5866
查看次数

Yaml:如何排除 VSTest@2 中的某些测试

目前,我们正在转向 AzureDevOps。我们有一些单元测试在代理上失败,但我们没有能力立即修复它们。在修复它们之前,我们希望将它们从管道中排除,并设置所有测试都应通过的策略,然后逐一修复它们。

让我说,我有4个exe,分别是ABE_uTest.exe、BBE_uTest.exe、CBE_uTest.exe和DBE_uTest.exe。我想排除 BBE 和 CBE。在文档页面(AzureDevOps VsTest)上,我找到了如何排除文件。

测试程序集版本2: | # 当 testSelector == TestAssemblies 时需要
# *test .dll
# ! *TestAdapter.dll
#!
\对象*

所以我认为只需 a*_uTest.exe !BBE* !CBE*就可以了。但我错过了一些东西,因为我无法让它发挥作用。它要么不过滤任何内容,要么过滤所有内容。这是 yaml 的相应部分。

- task: VSTest@2
  displayName: VsTest - testAssemblies
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: '*_uTest.exe
      !*BBE*'
    searchFolder: '$(BuildPlatform)_$(BuildConfiguration)\testbin\'
Run Code Online (Sandbox Code Playgroud)

testAssemblyVer2将是设置。我尝试只使用一个排除二进制文件以使其更简单。我尝试过'在开头和结尾有或没有角色。还尝试了一行和单独一行,但没有成功。我总是收到这样的消息:

##[warning]No test sources found matching the given filter '*_uTest.exe !BBE_uTest.exe'

使用 yaml 排除 AzureDevOps 中的文件的正确语法是什么?

vstest azure-pipelines

2
推荐指数
1
解决办法
3075
查看次数

NETSDK1045:当前的 .NET SDK 不支持“较新版本”作为目标

我创建了一个简单的 ASP.NET CORE 6 Web API。然后我把它推到了Github上。当我尝试在Azure Devops中创建管道时,出现错误。

C:\Program Files\dotnet\sdk\5.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET
   .TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support 
   targeting .NET 6.0.  Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports 
   .NET 6.0.
Run Code Online (Sandbox Code Playgroud)

我刚刚下载了 VS 2022 社区版。我已经安装了 .Net SDK 6。这是我的 csproj 文件

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
  </ItemGroup>

</Project>
Run Code Online (Sandbox Code Playgroud)

我选择了 Azure devops 建议的内容,所以这是我的 yml 文件

# ASP.NET
# Build and test ASP.NET projects.
# …
Run Code Online (Sandbox Code Playgroud)

azure-devops asp.net-core azure-pipelines

2
推荐指数
1
解决办法
7551
查看次数

Azure DevOps 和 Azure CLI:无法找到可执行文件

当尝试在基于 ubuntu 的 Azure DevOps 管道中运行简单的 Azure CLI 任务时,我收到以下错误消息:

##[error]Script failed with error: Error: Unable to locate executable file: 
'/home/vsts/work/_temp/azureclitaskscript1637831708745.bat'. 
Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. 
Also check the file mode to verify the file is executable.
Run Code Online (Sandbox Code Playgroud)

如果我正确地阅读了此内容,则未找到内联脚本,对吗?我在这里缺少什么?这是完整的 YAML:

trigger:
- main
- dev

pool:
  vmImage: ubuntu-latest

steps:
- task: AzureCLI@2
  inputs:
    azureSubscription: 'My Subscription Name'
    scriptType: 'batch'
    scriptLocation: 'inlineScript'
    inlineScript: 'az --version'
Run Code Online (Sandbox Code Playgroud)

azure azure-cli azure-devops azure-pipelines azure-pipelines-yaml

2
推荐指数
1
解决办法
8701
查看次数

AzurePowerShell 任务找不到 filePath

我尝试在 Azure Yaml Pipelines 中运行 PowerShell 脚本,但收到此错误:

##[error]The term 'D:\a\1\s\myPowershellFile.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Run Code Online (Sandbox Code Playgroud)

代码:

jobs:
  - deployment: Deploy
    displayName: Deploy
    environment: $(myEnvironment)
    pool:
      vmImage: 'windows-latest'

    strategy:
      runOnce:
        deploy:
          steps:          
          - task: AzurePowerShell@5
            displayName: 'Run Powershell script'
            inputs:
              azureSubscription: $(azureConnectionName)
              scriptType: filePath
              scriptPath: './myPowershellFile.ps1'
              azurePowerShellVersion: latestVersion
Run Code Online (Sandbox Code Playgroud)

该文件被推送到触发构建的分支的存储库。$(Pipeline.Workspace) …

azure azure-powershell azure-devops azure-pipelines azure-yaml-pipelines

2
推荐指数
1
解决办法
3384
查看次数

Azure DevOps Pipeline NPM 安装任务失败并出现 node-gyp 构建错误

我正在尝试在 Azure DevOps 中构建 Azure Pipeline。问题是当管道运行时,npm 构建任务中发生错误。难道是package.json中有一些过时的包?或者说 npm 已经过时了?

\n

请参阅管道开始运行的教程中的步骤 4:\n https://learn.microsoft.com/en-us/learn/modules/create-a-build-pipeline/6-create-the-pipeline

\n

管道中构建任务的屏幕截图:

\n

在此输入图像描述

\n

原始日志:

\n
2021-12-03T00:13:53.4119601Z ##[section]Starting: Run npm install\n2021-12-03T00:13:53.4130006Z ==============================================================================\n2021-12-03T00:13:53.4130664Z Task         : npm\n2021-12-03T00:13:53.4144256Z Description  : Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Azure Artifacts.\n2021-12-03T00:13:53.4145177Z Version      : 1.187.0\n2021-12-03T00:13:53.4145620Z Author       : Microsoft Corporation\n2021-12-03T00:13:53.4146127Z Help         : https://learn.microsoft.com/azure/devops/pipelines/tasks/package/npm\n2021-12-03T00:13:53.4146868Z ==============================================================================\n2021-12-03T00:13:54.7198556Z [command]/usr/local/bin/npm --version\n2021-12-03T00:13:55.4151672Z 8.1.0\n2021-12-03T00:13:56.0808980Z [command]/usr/local/bin/npm config list\n2021-12-03T00:13:56.3808693Z ; "env" config from environment\n2021-12-03T00:13:56.3811792Z \n2021-12-03T00:13:56.3813271Z userconfig = "/home/vsts/work/1/npm/13.npmrc" \n2021-12-03T00:13:56.3814393Z \n2021-12-03T00:13:56.3815603Z ; node bin location …
Run Code Online (Sandbox Code Playgroud)

npm-install azure-devops azure-pipelines

2
推荐指数
1
解决办法
1万
查看次数

Terraform Plan 停留在 Terraform:ADO 管道中的计划任务

在此输入图像描述我尝试按照以下链接通过 Azure Dev Ops Pipeline 使用 Terraform 部署应用程序服务

Azure开发运营实验室

我的地形文件如下:

网络应用程序.tf

terraform {
  required_version = "~> 1.0" 
  backend "azurerm" {
    storage_account_name = "__terraformstorageaccount__"
    container_name       = "terraform"
    key                  = "terraform.tfstate"
    }
}

provider "azurerm" {
  tenant_id       = var.tenant_id
  client_id       = var.client_id
  client_secret   = var.client_secret
  subscription_id = var.subscription_id
  features {}
}

resource "azurerm_resource_group" "dev" {
  name     = var.resource_group_name
  location = var.resource_group_location
}

resource "azurerm_app_service_plan" "dev" {
  name                = var.appserviceplan
  location            = var.resource_group_location
  resource_group_name = var.resource_group_name

  sku {
    tier = "Free"
    size = …
Run Code Online (Sandbox Code Playgroud)

azure azure-web-app-service azure-devops azure-pipelines terraform-provider-azure

2
推荐指数
1
解决办法
4269
查看次数