[英]How to use newer versions of Maven for builds in Azure Pipelines for CI/CD
I need Maven version 3.5.3 or above to build my project hosted on github. 我需要Maven版本3.5.3或更高版本来构建我在github上托管的项目。 The default version for maven used in Azure pipelines CI/CD is 3.3.9.
Azure管道CI / CD中使用的maven的默认版本是3.3.9。 I can see that there is a way to install a different version of java using Java tool installer .
我可以看到有一种方法可以使用Java工具安装程序安装不同版本的java。 I don't find such an option in their documentation for maven.
我在maven的文档中找不到这样的选项。
But for maven it is possible to specify the 但对于maven ,可以指定
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. 但作为一个新手,我不明白如何安装maven并在这里指定路径。
Any help on how to use a different version for my maven build in Azure pipelines CI/CD would be appreciated. 有关如何在Azure管道CI / CD中使用不同版本的maven构建的任何帮助将不胜感激。
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: 由于我在Ubuntu环境中,我能够通过使用脚本来下载maven并通过设置maven的路径来运行,如下所示:
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 . 您可以在此处找到适用于所有操作系统的yaml文件。
Thanks @starian chen-MSFT for the heads up. 感谢@starian chen-MSFT的领导。
Refer to these steps: 请参考以下步骤:
apache-maven-3.5.4-bin.zip
; Destination folder: $(build.sourcesdirectory)\\maven
) apache-maven-3.5.4-bin.zip
;目标文件夹: $(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
mvn --version
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.