Azure Devops第二管道消耗另一条管道的工件被困在工作中

发布于 2025-02-12 05:35:12 字数 4093 浏览 0 评论 0 原文

我们正在为Web .NET应用程序运行一组管道。触发管道(构建)正在馈送另一个管道(释放)。第二个,触发的管道被卡在作业上正在等待。我们使用的是Azure DevOps的云版本,只有1个由Azure托管的代理。

构建管道(部分)是以下

trigger:
  branches:
    include:
      - main

pr:
  - main

variables:
  solution: '**/*.sln'
  NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
  group: 'Global - BuildSet'

stages:
  - stage: build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    jobs:
      - job: Build
        displayName: Build

        steps:
          - task: NuGetToolInstaller@1
            displayName: 'NuGet tool installer'

          - task: Cache@2
            displayName: Cache
            inputs:
              key: 'nuget | "$(Agent.OS)" | **/packages.lock.json,!**/bin/**,!**/obj/**'
              path: '$(NUGET_PACKAGES)'
              cacheHitVar: 'CACHE_RESTORED'

          - task: NuGetCommand@2
            displayName: 'NuGet restore'
            condition: ne(variables.CACHE_RESTORED, true)
            inputs:
              command: 'restore'
              restoreSolution: '$(solution)'
          -...
          - publish: $(Build.artifactstagingdirectory)
            artifact: $(ArtifactName)

版本管道是以下

trigger: none
pr: none
resources:
  pipelines:
    - pipeline: 'bak-ak'
      source: 'BAK - Build'
      trigger:
        branches:
          - main

parameters:
  - name: 'stages'
    type: object

    default:
      - stage: development
        dependsOn:

      - stage: staging
        variableGroup:
          - group: 'Staging - BAK'
          - group: 'Staging - BuildSet'
        dependsOn: 'development'

variables:
  solution: '**/*.sln'
  NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
  group: 'Global - BuildSet'

stages:
  - ${{each stage in parameters.stages}}:
      - stage: ${{ stage.stage }}
        variables:
          - group: '${{ stage.stage }} - BAK'
          - group: '${{ stage.stage }} - BuildSet'
        dependsOn: ${{ stage.dependsOn }}
        displayName: Release
        pool:
          vmImage: $(vmImageName)

        jobs:
          - deployment: ${{ stage.stage }}
            displayName: ${{ stage.stage }}
            environment: ${{ stage.stage }}
            strategy:
              runOnce:
                deploy:
                  steps:
                    - download: 'BAK-Release'
                      artifact: $(ArtifactName)

                    - task: ExtractFiles@1
                      displayName: 'Extract files'
                      inputs:
                        destinationFolder: '$(Agent.BuildDirectory)/$(ArtifactName)'
                        archiveFilePatterns: '$(Agent.BuildDirectory)/$(ArtifactName)/**/*.zip'
                        cleanDestinationFolder: false
                    -...
                    - task: AzureWebApp@1
                      displayName: 'Deploy Azure App Service'
                      inputs:
                        azureSubscription: '$(AzureServiceConnection)'
                        appType: 'webApp'
                        appName: '$(WebAppName)'
                        package: '$(Agent.BuildDirectory)/$(ArtifactName)'

两个YML文件在同一git项目下,同一文件夹,同一Azure DevOps项目。发行管道背后的想法是由从构建管道成功构建并部署到N环境的成功触发的。每个环境的变量在库下,并且发行管线可以访问这些变量组。发行管线以正确的名称显示了当前两个不同阶段的阶段。我能够从发行管道中下载日志,并且可以看到所有变量已正确替换。不幸的是,我无法从发行管道中粘贴日志,因为它包含敏感信息。

构建管道从 deploymentConfiguration/build-azure-pipelines.yml 并且该版本管道从 deploymentConfiguration/Release-azure-pipelines.yml

构建和释放管道都设置为主要分支我正在使用的当前分支(不是Main)。 构建管道分支 释放管道分支

我已经创建了一个PR到Main,当我推上分支时,构建管道触发了一个构建,并且在完成后,释放管道开始,但在2之后悬挂2秒。

任何人都知道什么问题并且管道被卡住了吗?此时我没有想法。

We are running a set of pipelines for our web .net applications. A triggering pipeline (build) is feeding another pipeline (release). The second, triggered, pipeline is stuck on a job is pending. We are using the cloud version of Azure DevOps and only 1 agent, hosted by azure.

The build pipeline (portion of that) is the following

trigger:
  branches:
    include:
      - main

pr:
  - main

variables:
  solution: '**/*.sln'
  NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
  group: 'Global - BuildSet'

stages:
  - stage: build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    jobs:
      - job: Build
        displayName: Build

        steps:
          - task: NuGetToolInstaller@1
            displayName: 'NuGet tool installer'

          - task: Cache@2
            displayName: Cache
            inputs:
              key: 'nuget | "$(Agent.OS)" | **/packages.lock.json,!**/bin/**,!**/obj/**'
              path: '$(NUGET_PACKAGES)'
              cacheHitVar: 'CACHE_RESTORED'

          - task: NuGetCommand@2
            displayName: 'NuGet restore'
            condition: ne(variables.CACHE_RESTORED, true)
            inputs:
              command: 'restore'
              restoreSolution: '$(solution)'
          -...
          - publish: $(Build.artifactstagingdirectory)
            artifact: $(ArtifactName)

The release pipeline is the following

trigger: none
pr: none
resources:
  pipelines:
    - pipeline: 'bak-ak'
      source: 'BAK - Build'
      trigger:
        branches:
          - main

parameters:
  - name: 'stages'
    type: object

    default:
      - stage: development
        dependsOn:

      - stage: staging
        variableGroup:
          - group: 'Staging - BAK'
          - group: 'Staging - BuildSet'
        dependsOn: 'development'

variables:
  solution: '**/*.sln'
  NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
  group: 'Global - BuildSet'

stages:
  - ${{each stage in parameters.stages}}:
      - stage: ${{ stage.stage }}
        variables:
          - group: '${{ stage.stage }} - BAK'
          - group: '${{ stage.stage }} - BuildSet'
        dependsOn: ${{ stage.dependsOn }}
        displayName: Release
        pool:
          vmImage: $(vmImageName)

        jobs:
          - deployment: ${{ stage.stage }}
            displayName: ${{ stage.stage }}
            environment: ${{ stage.stage }}
            strategy:
              runOnce:
                deploy:
                  steps:
                    - download: 'BAK-Release'
                      artifact: $(ArtifactName)

                    - task: ExtractFiles@1
                      displayName: 'Extract files'
                      inputs:
                        destinationFolder: '$(Agent.BuildDirectory)/$(ArtifactName)'
                        archiveFilePatterns: '$(Agent.BuildDirectory)/$(ArtifactName)/**/*.zip'
                        cleanDestinationFolder: false
                    -...
                    - task: AzureWebApp@1
                      displayName: 'Deploy Azure App Service'
                      inputs:
                        azureSubscription: '$(AzureServiceConnection)'
                        appType: 'webApp'
                        appName: '$(WebAppName)'
                        package: '$(Agent.BuildDirectory)/$(ArtifactName)'

Both the yml files are under the same git project, same folder, same Azure DevOps project. The idea behind the release pipeline is to be triggered by a successful build from Build pipeline, and deploy to N environments. The variables for each environment is under a library and the release pipeline has access to those variable groups. The release pipeline displays currently the two different stages by their correct names. I am able to download logs from within the release pipeline, and I can see all the variables are been substituted correctly. Unfortunately I cannot paste the logs from the release pipeline because it contains sensitive information.

The Build pipeline consumes the yml from DeploymentConfiguration/build-azure-pipelines.yml Build pipeline yml location
And the Release pipeline consumes the yml from DeploymentConfiguration/release-azure-pipelines.yml Release pipeline yml location

Both the Build and Release pipeline have set as main branch the current branch I am working with (not main). Build pipeline branch Release pipeline branch

I have created a PR to main and when I am pushing on the branch, the build pipeline triggers a build and upon completion, the release pipeline starts but hangs afters 2 seconds.

Anyone has an idea of what is wrong and the pipeline gets stuck? I'm out of ideas at this point.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

濫情▎り 2025-02-19 05:35:12

我在设置中发现了问题。

在第二个管道中定义资源时,会触发自动下载伪像。这意味着发布管道不需要步骤

                    - download: 'BAK-Release'
                      artifact: $(ArtifactName)

不仅要与发布资源相同,因此,在我的情况下,它应该是 bak-ak 。参考:

resources:
  pipelines:
    - pipeline: 'bak-ak'
      source: 'BAK - Build'
      trigger:
        branches:
          - main

I found the problem with my setup.

When the resource is defined in the second pipeline, an auto download artifact is triggered. That means that the release pipeline does not need the step

                    - download: 'BAK-Release'
                      artifact: $(ArtifactName)

Not only that, the download string must be the same name as the release resource, in my case it should have been bak-ak. Ref:

resources:
  pipelines:
    - pipeline: 'bak-ak'
      source: 'BAK - Build'
      trigger:
        branches:
          - main
凉城已无爱 2025-02-19 05:35:12

在这里是REST API:构建 - 获取构建日志,您可以使用此API获取每个构建任务日志。

您是否在本地测试了Nuget配置?

Here is the Rest API: Builds - Get Build Logs, you could use this API to get every build task log.

Have you tested your nuget config locally?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文