Azure Devops-在第一阶段定义的作业,在所有阶段执行



我正在学习Azure DevOps Pipelines,我有一个场景,第一阶段定义的作业在所有阶段都在执行,尽管只在第一阶段定义。这不是我想要的行为,但由于我是新手,这实际上可能是预期的行为。你能看看下面的山和阿迪夫斯吗?任务任务:Maven@3.205.1在每个阶段执行。感谢

trigger:
- main
pool:
vmImage: "ubuntu-latest"
stages:
- stage: stage1
jobs:
- job: myJob
steps:
- task: Maven@3.205.1
inputs:
mavenPomFile: 'pom.xml'
mavenOptions: '-Xmx3072m'
javaHomeOption: 'JDKVersion'
jdkVersionOption: '11'
jdkArchitectureOption: 'x64'
publishJUnitResults: true
testResultsFiles: '**/surefire-reports/TEST-*.xml'
goals: 'clean install'
- stage: stage2
jobs:
- job: mySecondJob
steps:
- task: NodeTool@0
displayName: Node install
inputs:
versionSpec: '6.x' # The version we're installing
# Write the installed version to the command line
- script: which node
- stage: stage3
jobs:
- job: A
steps:
- script: exit 0
- job: B
dependsOn: A
condition: failed()
steps:
- script: echo this will run when A fails
- job: C
dependsOn:
- A
- B
condition: succeeded('B')
steps:
- script: echo this will run when B runs and succeeds

根据您的描述和关注点,如果您想设置任务:Maven@3.205.1在每个阶段执行,需要在每个阶段设置指定的任务,而不仅仅是在第一阶段。

因此,建议您可以使用YAML模板,下面是文档:Templates-Azure Pipelines | Microsoft Docs供您参考。从文档中,您可以了解如何将每个阶段设置为调用相同的模板。

最新更新