4

I am trying to have build and release pipeline on Azure DevOps services for the same I am using self hosted Linux agent runnig on linuxVM hosted in Azure.

Earlier the same pipeline was running on Microsoft hosted Agent there was no error.

Right now I am getting ##[error]No agent found in pool ProjectAgent which satisfies the specified demands: maven, Agent.Version -gtVersion 2.163.1

I have installed 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 #

Even in the Agent Capability its reflecting

enter image description here

Pipeline Yaml

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

Pipeline failed

enter image description here

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
Satyam Pandey
  • 593
  • 2
  • 10
  • 32
  • Does anyone know how azure devops agent collect the capabilities, because it cleared that though maven or ant or any other tools we install, we restart agent service but it won't appear default in the capabilities list and then we have to give it manually. – Jaydeep Soni Jan 25 '22 at 09:11
  • In case of java put `java true` but I got hint from this answer, thanks – Anup Yadav Nov 21 '22 at 09:14

2 Answers2

8

There is no maven in the capabilities, you can add it manually:

enter image description here

enter image description here

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
  • 1
    I had a similar error on Windows 10. "##[error]No agent found in pool which satisfies the following demand: visualstudio. All demands: msbuild, visualstudio, Agent.Version -gtVersion 2.115.0", and after adding "Name: visualstudio Value: true", it started to build. But the build failed with a more useful warning, "##[warning]Visual Studio was not found. Try installing a supported version of Visual Studio. See the task definition for a list of supported versions." – greg Nov 09 '21 at 18:53
  • 1
    In case of java put java true but I got hint from this answer. – Anup Yadav Nov 21 '22 at 09:15
0

You may just need to run ./env.sh and then restart the agent for it to take effect.

AmanicA
  • 4,659
  • 1
  • 34
  • 49