[英]How to use Artifactory Maven Build in Jenkins Pipeline
i am trying to publish my build artifacts via artifactory maven to my artifactory server. 我正在尝试通过工件Maven将我的构建工件发布到我的工件服务器。
stage("${buildType} publish to Artifactory") {
def server = Artifactory.server 'artifactory'
def rtMaven = Artifactory.newMavenBuild()
rtMaven.resolver server: server, releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot'
rtMaven.deployer server: server, releaseRepo: 'libs-release-local', snapshotRepo: 'libs-release-local-SNAPSHOT'
rtMaven.tool = 'maven tool name'
def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean package -Dskip.unit.tests=true -Dskip.integration.tests=true'
server.publishBuildInfo buildInfo
}
But the Job fails with 但是工作失败了
ERROR: Couldn't find Maven executable.
i tried to match the "maven tool name" with the name of maven in my jenkins tools, but it still doesn't work 我尝试将“ maven工具名称”与我的詹金斯工具中的maven名称进行匹配,但仍然无法正常工作
Any help appriciated 任何帮助
It seems that you "copy paste" the example without changing the variables. 似乎您在不更改变量的情况下“复制粘贴”了该示例。 In order for it to work you will need to verify the following: 为了使其正常工作,您需要验证以下内容:
You will need to check what is the name of the Artifactory instance in the Jenkins system configuration page. 您将需要在Jenkins系统配置页面中检查Artifactory实例的名称。 The name is something that you gave it once configured Artifactory in Jenkins. 该名称是您在Jenkins中配置好Artifactory后为其赋予的名称。
This will be the value under 'Server ID'. 这将是“服务器ID”下的值。 This value should be placed instead the 'Artifactory' in: 该值应放在“ Artifactory”中,而不是:
def server = Artifactory.server 'artifactory'
rtMaven.tool = 'maven tool name'
should also be replaced with the name you entered on the "Global Tool Configuration" for the Maven version you installed. rtMaven.tool = 'maven tool name'
也应替换为您在“全局工具配置”中为安装的Maven版本输入的名称。 Once doing the above this should work. 完成上述操作后,此方法应该起作用。
It seems that you are using the correct maven tool name
but not the correct Server ID
of your artifactory. 看来您使用的是正确的maven tool name
而不是工件的正确的Server ID
。
If you are not sure about the artifactory serverID
, you may alternatively specify the artifactory using artifactory server address
. 如果不确定artifactory serverID
,则可以使用artifactory server address
指定工件。
def server = Artifactory.newServer url: 'YOUR_ARTIFACTORY_URL', username: 'ARTIFACTORY_USERNAME', password: 'ARTIFACTORY_PASSWORD'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.