标签: azure-pipelines

Azure DevOps - 多个存储库签出

设想

  • 我的代码是一个存储库,我所有的依赖项都在另一个存储库(另一个项目)中,我需要构建我的代码。

以下是我的 azure-pipelines.yml

# File: azure-pipelines.yml

pool:
  vmImage: 'ubuntu-latest'

variables:
  phpVersion: 7.3

resources:
  repositories:
    - repository: myLibraries
      type: git
      name: myProject/libraries

steps:
- checkout: self
- checkout: myLibraries
  path: libraries

- script: |
    sudo update-alternatives --set php /usr/bin/php$(phpVersion)
    sudo update-alternatives --set phar /usr/bin/phar$(phpVersion)
    sudo update-alternatives --set phpdbg /usr/bin/phpdbg$(phpVersion)
    sudo update-alternatives --set php-cgi /usr/bin/php-cgi$(phpVersion)
    sudo update-alternatives --set phar.phar /usr/bin/phar.phar$(phpVersion)
    php -version
  displayName: 'Use PHP version $(phpVersion)'

Run Code Online (Sandbox Code Playgroud)

当我运行管道时,出现以下错误:

不支持检出存储库“myLibraries”。仅支持“self”和“none”。不支持签出多个存储库。

参考:

https://github.com/microsoft/azure-pipelines-yaml/blob/master/design/multicheckout.md https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view =azure-devops#using-other-repositories

azure-devops azure-pipelines

3
推荐指数
2
解决办法
9942
查看次数

yaml 文件问题“此上下文中不允许映射值”

我正在学习 Azure DevOps 管道。我在 YAML 文件中遇到错误并且难以修复它。有人可以帮我吗?

下面是错误:

():在第 3 行第 11 列的上下文中不允许映射值

我一直在使用 www.yamllint.com/ 来修复,但没有运气。(task:PowerShell@2默认情况下,代码中的部分是从 Azure DevOps 的“任务”选项中添加的)。

# Starter pipeline
- task:PowerShell@2
    inputs:
  filePath:'$(System.DefaultWorkingDirectory)/_learndevops/HelloWorld.ps1'
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
- task:PublishBuildArtifacts@1
  inputs:
    PathtoPublish:'$(Build.ArtifactStagingDirectory)'
    ArtifactName:'drop'
    publishLocation:'Container'
# https://aka.ms/yaml

trigger:
- master

pool:
  vmImage:'ubuntu-latest'

steps:
- script:echo Hello, world!
Run Code Online (Sandbox Code Playgroud)

yaml azure-devops azure-pipelines

3
推荐指数
1
解决办法
9763
查看次数

从 json 文件导入 Azure Devops 管道变量

我想使用 json 文件来存储 powershell 脚本使用的变量。在 azure devops 中,我配置了管道,管道包含带有变量列表的 powershell 脚本。我想使用 json 文件并将所有变量存储在此文件中。我想将 json 文件存储在 Azure 存储库中,并在管道启动后使用它。我不想使用可变组。我找到了这个解决方案 [ Json to Variable ] https://marketplace.visualstudio.com/items?itemName=OneLuckiDev.json2variable&targetId=02fbae5c-cc01-4c8b-a90f-7393a3156347但我读到了一些关于这个任务的不受欢迎的意见。有什么方法可以使用 json 文件作为存储变量的地方,或者我可以使用不同的文件格式?更新: 在此处输入图片说明

json azure-powershell azure-devops azure-pipelines

3
推荐指数
1
解决办法
6783
查看次数

根据 AzureDevOps CI 管道中的分支更改变量值

在 AzureDevOps 如何根据运行 CI 管道的分支更改变量的值。

就像 for devbranch var-value= " develop " 而 for masterbranch var-value= " master "。

continuous-integration azure-devops azure-pipelines

3
推荐指数
1
解决办法
899
查看次数

Azure DevOps 仅存档来自构建删除的选定文件?

有没有办法在构建任务后只存档选定的文件?我只找到了“归档文件”任务,但它完全归档了整个文件夹。

azure-devops azure-pipelines

3
推荐指数
1
解决办法
2016
查看次数

使用 Azure Pipeline 中的 SqlPackage 部署 DACPAC 会忽略参数并删除用户

我在 Azure 中有一个发布管道,我在其中传递了一个 .dacpac 工件(使用 VStudio 创建)以部署在本地 Sql Server 2016 中。它运行良好,但现在我想删除表、视图、函数和存储过程我的服务器通过 .dacpac。所以,我没有在我的VS项目,然后试图用选项部署/p:DropObjectsNotInSource=True沿/p:DoNotDropObjectType,甚至/p:ExcludeObjectType排除我不想被丢弃的东西。

但是不管这些过滤器如何,一旦作业开始,表就会被删除(如预期的那样),然后它会删除数据库用户。它还删除了我用于安装 Azure 代理的登录名的 db_owner 映射,然后尝试删除该登录名(这是配置为在部署期间进行身份验证的同一用户)。然后它失败并出现此错误:

Error SQL72014: .Net SqlClient Data Provider: Msg 15151, Level 16, State 1, Line 1 Cannot drop the user '<Domain>\<User>', because it does not exist or you do not have permission.

这很明显,因为刚刚删除了用户对数据库的权限。有什么建议可以避免这种情况,或者我唯一的选择是在完成后重新创建用户/权限?或者不完全使用该标志并通过部署后脚本执行所有“删除对象管道”?

作为参考,在我的发布任务上设置的附加参数是(它看起来很奇怪,但没有办法只指定我想要删除的对象):

/p:DropObjectsNotInSource=True /p:BlockOnPossibleDataLoss=false /p:DoNotDropObjectType="Aggregates,ApplicationRoles,Assemblies,AsymmetricKeys,BrokerPriorities,Certificates,ColumnEncryptionKeys,ColumnMasterKeys,Contracts,DatabaseRoles,DatabaseTriggers,Defaults,ExtendedProperties,ExternalDataSources,ExternalFileFormats,ExternalTables,Filegroups,FileTables,FullTextCatalogs,FullTextStoplists,MessageTypes,PartitionFunctions,PartitionSchemes,Permissions,Queues,RemoteServiceBindings,RoleMembership,Rules,SearchPropertyLists,SecurityPolicies,Sequences,Services,Signatures,SymmetricKeys,Synonyms,UserDefinedDataTypes,UserDefinedTableTypes,ClrUserDefinedTypes,Users,XmlSchemaCollections,Audits,Credentials,CryptographicProviders,DatabaseAuditSpecifications,DatabaseScopedCredentials,Endpoints,ErrorMessages,EventNotifications,EventSessions,LinkedServerLogins,LinkedServers,Logins,Routes,ServerAuditSpecifications,ServerRoleMembership,ServerRoles,ServerTriggers" /p:ExcludeObjectType="Aggregates,ApplicationRoles,Assemblies,AsymmetricKeys,BrokerPriorities,Certificates,ColumnEncryptionKeys,ColumnMasterKeys,Contracts,DatabaseRoles,DatabaseTriggers,Defaults,ExtendedProperties,ExternalDataSources,ExternalFileFormats,ExternalTables,Filegroups,FileTables,FullTextCatalogs,FullTextStoplists,MessageTypes,PartitionFunctions,PartitionSchemes,Permissions,Queues,RemoteServiceBindings,RoleMembership,Rules,SearchPropertyLists,SecurityPolicies,Sequences,Services,Signatures,SymmetricKeys,Synonyms,UserDefinedDataTypes,UserDefinedTableTypes,ClrUserDefinedTypes,Users,XmlSchemaCollections,Audits,Credentials,CryptographicProviders,DatabaseAuditSpecifications,DatabaseScopedCredentials,Endpoints,ErrorMessages,EventNotifications,EventSessions,LinkedServerLogins,LinkedServers,Logins,Routes,ServerAuditSpecifications,ServerRoleMembership,ServerRoles,ServerTriggers"

sql-server dacpac sqlpackage azure-devops azure-pipelines

3
推荐指数
1
解决办法
895
查看次数

为什么此 ASP.NET Core Docker 构建在 Azure Pipelines 中失败?

在 Azure Pipelines 中构建 ASP.NET Core 项目时,下面的 YAML 文件仅在将解决方案和项目放在同一目录中时才有效。不需要将解决方案和项目放在同一目录下,可以对下面的YAML文件做什么?这在单个解决方案中多个项目的情况下很重要。

以下是采取的步骤:

  1. 使用 Visual Studio 2019 创建了支持 Linux Docker 容器的新 ASP.NET Core 3.1 项目。
  2. 推送到 Azure 存储库“DockerTest”。
  3. 使用模板“Docker: Build and push an image to Azure Container Registry”创建了管道,它基本上生成了下面的 YAML。

这导致在构建过程中出现以下错误:

复制失败:stat /var/lib/docker/tmp/docker-builder701699653/DockerTest/DockerTest.csproj:没有这样的文件或目录

azure-pipelines.yml

# Docker
# Build and push an image to Azure Container Registry
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker

trigger:
- master

resources:
- repo: self

variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: 'example-connection-string'
  imageRepository: 'dockertest'
  containerRegistry: …
Run Code Online (Sandbox Code Playgroud)

docker azure-devops azure-pipelines

3
推荐指数
1
解决办法
583
查看次数

Azure Devops:如何在发布管道期间添加自动化集成测试

我有一个分阶段发布管道,它部署到开发,然后部署到分阶段。

我希望我的集成测试项目仅在部署到暂存之前在发布管道期间运行。我怎么做?是否有特定的测试任务可以在分阶段部署之前挂钩?像部署前任务之类的?

azure-devops azure-pipelines azure-pipelines-release-pipeline

3
推荐指数
2
解决办法
6877
查看次数

Azure 发布管道,在失败阶段后继续

我有以下 azure 发布管道:

在此处输入图片说明

问题是我有时需要离开左阶段才能失败,但同时,即使失败了,仍然应该执行右阶段,这可能吗?

我发现的唯一一件事是“即使选定的阶段部分成功也触发”,但如果前一阶段失败,则它不起作用。

在此处输入图片说明

azure azure-pipelines azure-pipelines-release-pipeline

3
推荐指数
1
解决办法
1764
查看次数

将环境变量注入图像的构建阶段

为基于 Django 的 API 开发 CI/CD 管道。我需要在构建阶段注入环境变量才能成功构建图像。

  • python manage.py collectstaticDockerfile在构建映像时运行
  • collectstatic需要SECRET_KEYsettings.py运行
  • SECRET_KEY在此阶段为空,因为它是用os.environ['SECRET_KEY]
  • 因为是空的,所以构建失败
  • 因此,我需要设置环境来拥有这个变量

我无法将这么多内容放在一起,所以想看看是否有人可以帮助我。

这是我到目前为止所拥有的:

Azure管道

在此输入图像描述

azure-pipelines.yml

trigger:
  branches:
    include:
    - master

resources:
- repo: self

variables:
  # Container registry service connection established during pipeline creation
  secretKey: $(SECRET_KEY)

  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build and push stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - bash:
      env:
        SECRET_KEY: $(secretKey)
    - …
Run Code Online (Sandbox Code Playgroud)

azure docker dockerfile azure-devops azure-pipelines

3
推荐指数
1
解决办法
3615
查看次数