Azure Devops 管道在 ci 和开发部署阶段之间调用单独的 e2e 存储库
Azure Devops pipeline call separate e2e repo between ci and dev deployment stages
我有一个用于具有多个阶段的项目的 yaml 构建管道,它 运行s build_and_test 然后如果成功它 运行s ci_deployment,然后 dev_deployment 等。我想在 CI 和 DEV 之间添加一个阶段,运行 是一个单独的回购管道,在这种情况下它是一个 ReadyApi 回购,将 运行 api 测试针对 CI 环境,因此如果它失败,我们会阻止构建继续进行 DEV。
当我 运行 该管道时,我已经获得了 readyApi 管道 运行 针对环境的测试,但我不知道如何将其绑定到我的另一个管道的中间阶段管道。
所以我的问题是如何将阶段写入 运行 一个单独的管道,这对使用 yaml 非常陌生,因此非常感谢任何对此的帮助或可以帮助我理解的资源。
ReadyApi 管道:
---
trigger:
batch: false
branches:
include:
- trunk
pool:
name: OnPrem TestAgents
demands: TestRunner -equals ReadyAPI
steps:
- script: |
powershell 1 | "C:\Program Files (x86)\Java\jre1.8.0_241\bin\java.exe" -jar "C:\ready-api-license-manager\ready-api-license-manager-1.3.2.jar" -s licenseServerUrl
echo alma
displayName: 'Command Line Script'
- task: SoapUIProForAzureDevOpsTask@1
displayName: 'SoapUI Pro for Azure DevOps'
inputs:
project: 'ReadyAPI'
testSuite: API
projectPassword: 'unencryptkey'
- task: PublishTestResults@2
displayName: 'Publish Test Results **/*.xml'
inputs:
testResultsFiles: '**/*.xml'
searchFolder: '$(Common.TestResultsDirectory)'
mergeTestResults: true
failTaskOnFailedTests: true
我要更新的主要构建管道:
---
trigger:
batch: false
branches:
include:
- trunk
pool: "poolName"
variables:
buildMajor: 1
buildMinor: 3
stages:
- stage: build_and_test
displayName: Build and Test
variables:
azureResourceGroup:
azureInfrastructureStateStorageAccount:
environmentName: ci
jobs:
- job: build_image
- job: run_unit_test
- job: run_component_test
- job: build_and_push_container
- stage: ci_deployment
variables:
deployment_name: $(serviceName)
namespace: ci
environmentName: ci
buildid: $(buildVersion).$(Build.BuildNumber).$(Build.SourceVersion)
minReplicas: 1
maxReplicas: 5
dependsOn: build_and_test
jobs:
- deployment: deploy_to_ci
environment: ci
displayName: Deploy to ci
strategy:
runOnce:
deploy:
steps:
- template: pipelines/azure-pipelines-deploy.yaml
parameters:
environmentName: $(environmentName)
aadPodIdentityName: $(aadPodIdentityName)
appConfigName: $(appConfigName)
keyVaultName: $(keyVaultName)
- stage: dev_deployment
variables:
deployment_name: $(serviceName)
namespace: dev
environmentName: dev
buildid: $(buildVersion).$(Build.BuildNumber).$(Build.SourceVersion)
minReplicas: 3
maxReplicas: 10
dependsOn: ci_deployment
jobs:
- deployment: deploy_to_dev
environment: dev
displayName: Deploy to dev
strategy:
runOnce:
deploy:
steps:
- template: pipelines/azure-pipelines-deploy.yaml
parameters:
environmentName: $(environmentName)
aadPodIdentityName: $(aadPodIdentityName)
appConfigName: $(appConfigName)
keyVaultName: $(keyVaultName)
如果您想阻止继续进行原始管道,我建议您使用此扩展程序 Trigger Build Task
您可以在此处定义它在 ci_deployment
和 dev_deployment
之间的阶段触发,因此它将等待您的 运行 测试成功:
- stage: ci_tests
dependsOn: ci_deployment
jobs:
- job:
steps:
- task: TriggerBuild@3
displayName: 'Trigger a new build of Validate-BuildVariable Update'
inputs:
buildDefinition: 'Your build name'
useSameBranch: false
branchToUse: master
waitForQueuedBuildsToFinish: true
authenticationMethod: 'OAuth Token'
password: $(System.AccessToken)
- stage: dev_deployment
.....
dependsOn: ci_tests
我有一个用于具有多个阶段的项目的 yaml 构建管道,它 运行s build_and_test 然后如果成功它 运行s ci_deployment,然后 dev_deployment 等。我想在 CI 和 DEV 之间添加一个阶段,运行 是一个单独的回购管道,在这种情况下它是一个 ReadyApi 回购,将 运行 api 测试针对 CI 环境,因此如果它失败,我们会阻止构建继续进行 DEV。
当我 运行 该管道时,我已经获得了 readyApi 管道 运行 针对环境的测试,但我不知道如何将其绑定到我的另一个管道的中间阶段管道。
所以我的问题是如何将阶段写入 运行 一个单独的管道,这对使用 yaml 非常陌生,因此非常感谢任何对此的帮助或可以帮助我理解的资源。
ReadyApi 管道:
---
trigger:
batch: false
branches:
include:
- trunk
pool:
name: OnPrem TestAgents
demands: TestRunner -equals ReadyAPI
steps:
- script: |
powershell 1 | "C:\Program Files (x86)\Java\jre1.8.0_241\bin\java.exe" -jar "C:\ready-api-license-manager\ready-api-license-manager-1.3.2.jar" -s licenseServerUrl
echo alma
displayName: 'Command Line Script'
- task: SoapUIProForAzureDevOpsTask@1
displayName: 'SoapUI Pro for Azure DevOps'
inputs:
project: 'ReadyAPI'
testSuite: API
projectPassword: 'unencryptkey'
- task: PublishTestResults@2
displayName: 'Publish Test Results **/*.xml'
inputs:
testResultsFiles: '**/*.xml'
searchFolder: '$(Common.TestResultsDirectory)'
mergeTestResults: true
failTaskOnFailedTests: true
我要更新的主要构建管道:
---
trigger:
batch: false
branches:
include:
- trunk
pool: "poolName"
variables:
buildMajor: 1
buildMinor: 3
stages:
- stage: build_and_test
displayName: Build and Test
variables:
azureResourceGroup:
azureInfrastructureStateStorageAccount:
environmentName: ci
jobs:
- job: build_image
- job: run_unit_test
- job: run_component_test
- job: build_and_push_container
- stage: ci_deployment
variables:
deployment_name: $(serviceName)
namespace: ci
environmentName: ci
buildid: $(buildVersion).$(Build.BuildNumber).$(Build.SourceVersion)
minReplicas: 1
maxReplicas: 5
dependsOn: build_and_test
jobs:
- deployment: deploy_to_ci
environment: ci
displayName: Deploy to ci
strategy:
runOnce:
deploy:
steps:
- template: pipelines/azure-pipelines-deploy.yaml
parameters:
environmentName: $(environmentName)
aadPodIdentityName: $(aadPodIdentityName)
appConfigName: $(appConfigName)
keyVaultName: $(keyVaultName)
- stage: dev_deployment
variables:
deployment_name: $(serviceName)
namespace: dev
environmentName: dev
buildid: $(buildVersion).$(Build.BuildNumber).$(Build.SourceVersion)
minReplicas: 3
maxReplicas: 10
dependsOn: ci_deployment
jobs:
- deployment: deploy_to_dev
environment: dev
displayName: Deploy to dev
strategy:
runOnce:
deploy:
steps:
- template: pipelines/azure-pipelines-deploy.yaml
parameters:
environmentName: $(environmentName)
aadPodIdentityName: $(aadPodIdentityName)
appConfigName: $(appConfigName)
keyVaultName: $(keyVaultName)
如果您想阻止继续进行原始管道,我建议您使用此扩展程序 Trigger Build Task
您可以在此处定义它在 ci_deployment
和 dev_deployment
之间的阶段触发,因此它将等待您的 运行 测试成功:
- stage: ci_tests
dependsOn: ci_deployment
jobs:
- job:
steps:
- task: TriggerBuild@3
displayName: 'Trigger a new build of Validate-BuildVariable Update'
inputs:
buildDefinition: 'Your build name'
useSameBranch: false
branchToUse: master
waitForQueuedBuildsToFinish: true
authenticationMethod: 'OAuth Token'
password: $(System.AccessToken)
- stage: dev_deployment
.....
dependsOn: ci_tests