我正在尝试在 Azure DevOps 服务上构建和发布管道,就像我使用在 Azure 托管的 linuxVM 上运行的自托管 Linux 代理一样。
早些时候,相同的管道在 Microsoft 托管代理上运行时没有出现错误。
现在我正在##[error]No agent found in pool ProjectAgent which satisfies the specified demands: maven, Agent.Version -gtVersion 2.163.1
我已经在自托管Linux代理上安装了Java a和maven
:/home/-agent/_work/2/s/kubernetes # echo $JAVA_HOME
/usr/lib64/jvm/java
:/home/l-agent/_work/2/s/kubernetes # echo $M2_HOME
/opt/apache-maven-3.6.3
:/home/heisoul-agent/_work/2/s/kubernetes #
Run Code Online (Sandbox Code Playgroud)
即使在代理能力中也反映了
管道Yml
# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/java
resources:
- repo: self
trigger:
batch: true
branches: …Run Code Online (Sandbox Code Playgroud) maven-3 maven azure-devops azure-pipelines azure-devops-pipelines
我正在尝试在 Azure DevOps 中构建 YAML 发布管道,为此我创建了多个分支来保存特定于环境的文件
我还创建了 4 个发布管道:
问题:每当我在任何分支中进行任何更改时,所有分支管道都会开始运行。如果我运行单独的管道,它工作得很好。
# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml
trigger:
- acc
pool:
name: 'Agent'
steps:
- task: Kubernetes@1
displayName: 'Deploy on K8s Cluster'
inputs:
connectionType: 'Azure Resource Manager'
azureSubscriptionEndpoint: 'vs-aks-sc'
azureResourceGroup: 'azwe-rg-01'
kubernetesCluster: 'azwe-aks-01'
command: 'apply'
arguments: '-f $(System.DefaultWorkingDirectory)/kubernetes/acc.yaml'
Run Code Online (Sandbox Code Playgroud)
azure-devops azure-pipelines multibranch-pipeline azure-devops-pipelines
这里我尝试使用terraform创建aks,使用azure-devops将资源部署到azure。管道作业在一秒内失败。下面是管道代码。
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
stages:
- stage: TerraformValidate
jobs:
- job: TerraformValidateJob
continueOnError: false
steps:
- task: PublishPipelineArtifact@1
displayName: Publish Artifacts
inputs:
targetPath: '$(System.DefaultWorkingDirectory)/terraform-manifests'
artifact: 'terraform-manifests-out'
publishLocation: 'pipeline'
- task: TerraformInstaller@0
displayName: Terraform Install
inputs:
terraformVersion: 'latest'
- task: TerraformCLI@0
displayName: Terraform Init
inputs:
command: 'init'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
backendType: 'azurerm'
backendServiceArm: ''
backendAzureRmResourceGroupName: ''
backendAzureRmStorageAccountName: ''
backendAzureRmContainerName: ''
backendAzureRmKey: 'aks-base.tfstate'
allowTelemetryCollection: false
- task: TerraformCLI@0
displayName: Terraform Validate
inputs:
command: 'validate'
workingDirectory: '$(System.DefaultWorkingDirectory)/terraform-manifests'
allowTelemetryCollection: false
Run Code Online (Sandbox Code Playgroud)