##[错误]在池代理中找不到满足指定要求的代理:maven,Agent.Version -gtVersion 2.163.1

##[error]No agent found in pool Agent which satisfies the specified demands: maven, Agent.Version -gtVersion 2.163.1

我正在尝试在 Azure DevOps 服务上构建和发布管道,因为我正在使用自托管 Linux 代理在 Azure 托管的 linuxVM 上运行。

早些时候,同一管道 运行 在 Microsoft 托管代理上没有错误。

现在我得到 ##[error]No agent found in pool ProjectAgent which satisfies the specified demands: maven, Agent.Version -gtVersion 2.163.1

我已经安装了 Java aand maven on selfhosted Linux Agent

:/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 #

即使在 Agent Capability 中也反映了它

管道 Yaml

# Maven
# Build your Java project and run tests with Apache Maven.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/java

resources:
- repo: self

trigger:
  batch: true
  branches:
    include: 
    - main

pool:
  name: 'ProjectAgent'    
    
variables:
  tags: '$(Build.BuildNumber)'
  
- task: MavenAuthenticate@0
  displayName: 'Maven Authenticate'
  inputs:
    artifactsFeeds: myapp-snapshots,myapp-releases


- task: Maven@3
  displayName: 'Code Scan'
  inputs:
    mavenPomFile: '$(System.DefaultWorkingDirectory)/app-solution/core/build/maven/pom.xml'
    goals: package
    mavenAuthenticateFeed: true
    publishJUnitResults: true
    sonarQubeRunAnalysis: true
    sqMavenPluginVersionChoice: 'latest'

管道失败

capabilities里面没有maven,可以手动添加: