How to use newer versions of Maven for builds in Azure Pipelines for CI/CD How to use newer versions of Maven for builds in Azure Pipelines for CI/CD azure azure

How to use newer versions of Maven for builds in Azure Pipelines for CI/CD


Since I am on an Ubuntu environment I was able to get this running by using a script to download maven and by setting the path for maven as follows:

pool:  vmImage: 'Ubuntu 16.04'steps:- script: 'wget http://www-eu.apache.org/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip'- task: ExtractFiles@1  inputs:      archiveFilePatterns: 'apache-maven-3.5.4-bin.zip'      destinationFolder: '$(build.sourcesdirectory)/maven'- task: Maven@3  inputs:    mavenPomFile: 'pom.xml'    mavenOptions: '-Xmx3072m'    javaHomeOption: 'JDKVersion'    jdkVersionOption: '1.8'    jdkArchitectureOption: 'x64'    goals: 'clean install -P ballerina'    mavenVersionOption: 'Path'    mavenDirectory: '$(build.sourcesdirectory)/maven/apache-maven-3.5.4'    mavenSetM2Home: true

You can find the yaml file that works for all OSes here.

Thanks @starian chen-MSFT for the heads up.


Refer to these steps:

  1. Download maven installer package and add to source control (You can download it during build/release too)
  2. Add Extract files task (Archive file patterns: apache-maven-3.5.4-bin.zip; Destination folder: $(build.sourcesdirectory)\maven)
  3. Add PowerShell task:

code:

Write-Host "##vso[task.setvariable variable=M2_HOME;]$(build.sourcesdirectory)\maven\apache-maven-3.5.4"Write-Host "##vso[task.setvariable variable=MAVEN_HOME;]$(build.sourcesdirectory)\maven\apache-maven-3.5.4"Write-Host "##vso[task.prependpath]$(build.sourcesdirectory)\maven\apache-maven-3.5.4\bin"
  1. Add PowerShell task to check version: mvn --version