I need Maven version 3.5.3 or above to build my project hosted on github. The default version for maven used in Azure pipelines CI/CD is 3.3.9. I can see that there is a way to install a different version of java using Java tool installer. I don't find such an option in their documentation for maven.
But for maven it is possible to specify the
mavenVersionOption: 'Default' # Options: default, path
mavenDirectory: # Required when mavenVersionOption == Path
But being a newbie I don't understand how to install maven and specify a path here.
Any help on how to use a different version for my maven build in Azure pipelines CI/CD would be appreciated.
You can deploy a Spring Boot app or containerized Spring Boot app or any Web app to Azure App Service Linux or Windows: Deploy a Spring Boot app to Azure App Service. Deploy a containerized Spring Boot app to Azure App Service. Deploy a containerized Spring Boot app to Azure App Service via Azure Container Registry.
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:
apache-maven-3.5.4-bin.zip
; Destination folder: $(build.sourcesdirectory)\maven
)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"
mvn --version
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With