标签: azure-pipelines

ARM模板可选参数

我有一个非常简单的带有参数的 ARM 模板 json 文件:

"StorageName": {
  "type": "string",
  "defaultValue": ""
},
Run Code Online (Sandbox Code Playgroud)

和资源:

{
      "name": "[parameters('StorageName')]",
      "type": "Microsoft.Storage/storageAccounts",
      "location": "[resourceGroup().location]",
      "apiVersion": "2018-02-01",
      "condition": "[greater(length(parameters('StorageName')), 0)]",
      "sku": {
        "name": "[parameters('StorageType')]"
      },
      "dependsOn": [],
      "tags": {
        "displayName": "..storage"
      },
      "properties": {
        "accountType": "[parameters('StorageType')]",
        "supportsHttpsTrafficOnly": true,
        "encryption": {
          "services": {
            "blob": {
              "enabled": true
            },
            "file": {
              "enabled": true
            }
          },
          "keySource": "Microsoft.Storage"
        }
      },
      "kind": "[parameters('StorageKind')]"
    }
Run Code Online (Sandbox Code Playgroud)

StorageName具有默认为空字符串值,这是基于微软的文档有效值-默认值可以是一个空字符串。

condition如果仅提供名称,我使用功能来创建存储

"condition": "[greater(length(parameters('StorageName')), 0)]",
Run Code Online (Sandbox Code Playgroud)

但是当我运行这个 ARM 模板时,我仍然在 vso 控制台中收到一个错误:

2018-08-13T08:46:56.1816398Z …
Run Code Online (Sandbox Code Playgroud)

azure azure-rm-template azure-pipelines

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

使用 Github Repo 的 Azure/DevOps - 要构建的项目的路径

我正在尝试在 VSTS(Azure DevOps)到 Azure WebApp 的帮助下为 Github 上的项目创建 CI/CD 管道。

我正处于该过程的开始阶段,并且一直坚持让我的项目直接在 VSTS 中构建。

后端项目为DotNetCore项目,前端尚未确定。

我在 github 上的存储库看起来像这样

/
 -> Project.FrondEnd
 -> Project.BackEnd
 -> Documents
 -> .gitignore
 -> readme.md
Run Code Online (Sandbox Code Playgroud)

在文件夹 Project.BackEnd 中,它将如下所示:

/Project.BackEnd
 -> Project.Api (Entry point of the server app)
 -> Project.Entities
 -> Project.DataAccess
 -> Project.Services
 -> Project.sln
Run Code Online (Sandbox Code Playgroud)

当我在 VSTS 上配置管道时,我需要编写 pipeline.yml 文件,但似乎我缺少一些关于如何指向我的服务器入口点以便它可以构建项目的知识!

这是我的 yml 文件

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'
Run Code Online (Sandbox Code Playgroud)

这样它就行不通了,我收到了这条消息:

错误 MSB1003:指定项目或解决方案文件。当前工作目录不包含项目或解决方案文件。

我试图将步骤更改为这样的 …

azure-devops azure-pipelines

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

Azure DevOps 在构建主机之间传递动态分配的变量

我在 vs2017-win2016 构建代理上使用 Azure DevOps 来配置一些使用 Terraform 的基础设施。

我想知道的是,可以将动态分配的 IP 地址的主机的 Terraform 输出传递给运行不同构建代理的第二个作业。

我可以在第一个 Job BASTION_PRIV_IP=xxxx BASTION_PUB_IP=1.1.1.1 中传递这些来构建变量

但是无法让这些变量看起来似乎与运行 ubuntu-16.04 的第二个构建代理一起使用我能够传递任何静态定义的参数,例如我在作业开始之前定义的 Azure 资源组名称,它只是动态分配的参数.

build-agent azure-devops azure-pipelines

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

如何在 Build Yaml 中进行 dotnet 发布

如果需要dotnet publish.Net Core 2.1. 提到无法弄清楚确切的方式。

它在下面说,yaml方式应该是什么

要使此任务起作用,您必须已使用 dotnet publish --output $(Build.ArtifactStagingDirectory) 命令将构建的输出发布到此目录。要在发布前将其他文件复制到此目录,

例如下面如何build.yaml在类应用程序中表示(API 解决方案)

dotnet publish ~/projects/app1/app1.csproj
Run Code Online (Sandbox Code Playgroud)

下面试过

- task: DotNetCoreCLI@2
      displayName: "Prepare Publish Files"
      inputs:
        command: publish
        projects: ""
        arguments: --output $(Build.ArtifactStagingDirectory)/src/xxx.EndToEnd.Integration.Tests/xxx.EndToEnd.Integration.Tests.csproj
Run Code Online (Sandbox Code Playgroud)

但是得到以下错误,实际上我的是 API 解决方案,我试图在其中发布 end2end 测试并在部署后运行它们。

##[error]No web project was found in the repository. Web projects are identified by presence of either a web.config file or wwwroot folder in the directory.
##[error]Project file(s) matching the specified pattern were not found.
Run Code Online (Sandbox Code Playgroud)

yaml azure-pipelines asp.net-core-2.1

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

如何根据分支触发器在 yml 文件中运行不同的步骤

如何使 YAML 文件触发和检出分支并运行不同的步骤?

我正在处理 azure 的 YAML 文件,我想在我的主分支中运行某些步骤,并在 QA 分支中运行其他步骤。

trigger:
- master
pool:
  vmImage: 'Ubuntu-16.04'
steps:
- script: ls $(Build.Repository.LocalPath)
  displayName: 'printing the ls
Run Code Online (Sandbox Code Playgroud)

我想检查主节点并运行一个步骤,但是如果我想触发 QA 分支上的某些更改,请检查 QA 分支并运行其他步骤。YAML 应该是什么样的?

azure azure-devops azure-pipelines

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

以前的 Azure Pipeline Build 中的预定义变量

如何获取在过去 Azure 管道构建中使用的预定义变量。

当我导航到这个构建时,我可以看到日志,许多信息,但不是该构建时预定义变量的实际值。

我设法看到排队的时间变量,但只有三个:BuildConfiguration,BuildPlatformsystem.debug

例如,我如何检查该特定构建中的Build.DefinitionNameBuild.BuildNumber使用了什么?

continuous-integration azure-devops azure-pipelines

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

Azure DevOps Pipeline 测试显示部分成功

我最近将我的测试添加到 Azure DevOps 管道,但是当我在发布管道中运行测试时,我收到以下错误和一个黄色符号,表示部分成功。我该如何解决这个问题?

The STDIO streams did not close within 10 seconds of the exit event from process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe'. This may indicate a child process inherited the STDIO streams and has not yet exited.
2019-05-02T08:36:57.6622077Z ##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
2019-05-02T08:36:57.6713607Z ##[error]Error: The process 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe' failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

automated-tests azure-devops azure-pipelines

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

如何在 git 的属性文件中使用管道变量

在 Azure 管道中,我下载了 kubernetes deployment.yml 属性文件,其中包含以下内容。

spec:
  imagePullSecrets:
  - name: some-secret
  containers:
  - name: container-name
    image: pathtoimage/data-processor:$(releaseVersion)
    imagePullPolicy: Always
    ports:
    - containerPort: 8088
    env:
Run Code Online (Sandbox Code Playgroud)

我的目的是从管道变量中获取值$(releaseVersion)。但似乎kubernetes任务不允许从管道变量访问这个值。

我尝试使用内联配置类型并且它有效。这意味着如果我将与内联内容相同的配置复制到kubernetes任务配置,它就可以工作。

无论如何,我可以使它适用于文件中的配置吗?

kubernetes azure-devops azure-pipelines azure-pipelines-release-pipeline azure-aks

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

如何在 cd 的 azure 管道中捕获和保留通用工件的工件包版本

我有这个使用 yaml 的 azure devops ci/cd 管道。我的 yaml 有两个阶段 CI 和 CD。我的 CI 阶段有一项名为BuildandDeploy 的工作。CD 阶段有一项部署作业。我正在使用通用工件来发布和下载相同的工件。在 CD 阶段,我使用UniversalPackagesdevops 任务下载工件。该任务有一个名为vstsPackageVersion的输入变量,它是通用工件中显示的包版本。我知道可以使用的另外两个变量$(Build.BuildId)$(Build.BuildNumber). 作为临时工作,我正在为通用工件硬编码包版本。

我无法使用任一内置变量下载工件。由于 CI 和 CD 在同一个管道中,有没有办法存储和检索工件的包版本?有没有像latest我可以用来从通用包中获取最新工件的标识符。

# specific branch build with batching
trigger:
  batch: true
  branches:
    include:
    - master

stages:
- stage: CI
  jobs:
  - job: BuildAndPublish
    pool:
      vmImage: 'Ubuntu-16.04'
    steps:
    - 
      script: |
          docker build -t $(dockerId).azurecr.io/$(imageName):$(version) .
          docker login -u $(dockerId) -p $(pswd) $(dockerId).azurecr.io 
          docker push $(dockerId).azurecr.io/$(imageName):$(version) …
Run Code Online (Sandbox Code Playgroud)

continuous-delivery azure-devops azure-pipelines

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

在 YAML 构建中使用任务组的 Azure DevOps

我创建了一个任务组来封装一些功能。如果我使用常规构建,我可以通过普通向导添加任务组。

不幸的是,我需要在 YAML 构建中使用任务组。我无法查看“旧”版本的 YAML 来查看这应该如何发生。

我尝试过的事情:

  - task: TaskGroupName@1
    displayName: 'RunTests' 
    inputs:
      TestConfiguration: 'some.xml'
      TestCaseFilter: $(TestCaseFilter)
      UnitTestFolders: $(UnitTestFolders)
Run Code Online (Sandbox Code Playgroud)

azure-devops azure-pipelines

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