Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
627 views
in Technique[技术] by (71.8m points)

jenkins-pipeline - 如何在Jenkinsfile中将构建部署到其他Artifactory?(How to deploy builds to different Artifactory in Jenkinsfile?)

I have a Jenkinsfile and I want to be able to deploy maven build to different artifactory based on the build.

(我有一个Jenkinsfile,我希望能够根据构建将Maven构建部署到其他工件。)

For instance if the Jenkinsfile is triggered when I push my code to development branch I want to deploy the build from development branch to "maven-dev" artifactory.

(例如,如果在我将代码推送到开发分支时触发了Jenkinsfile,我想将构建从开发分支部署到“ maven-dev”工件。)

I have 4 Git branches (dev, preprod, stage, prod) and subsequently 4 different Artifactory locations (maven-dev, maven-preprod, maven-stage, maven-prod).

(我有4个Git分支(dev,preprod,stage,prod),然后有4个不同的Artifactory位置(maven-dev,maven-preprod,maven-stage,maven-prod)。)

I have the following script in my Jenkinsfile for build deployment however, I need to know what changes I need to make to the following script in order to be able to deploy each build (mentioned above) to the corresponding Artifactory location?

(我的Jenkinsfile中有以下脚本用于构建部署,但是,我需要知道我需要对以下脚本进行哪些更改才能将每个构建(上述)部署到相应的Artifactory位置?)

script {
 def server = Artifactory.server('artifacts')
 def rtMaven = Artifactory.newMavenBuild()
 rtMaven.deployer server: server, releaseRepo: 'maven-prod', snapshotRepo: 'maven-dev'
 def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'clean install -DskipTests=true -q -Dartifactory.publish.buildInfo=true'
 buildInfo = Artifactory.newBuildInfo()
 server.publishBuildInfo buildInfo
}
  ask by Hosein Zarifi translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You should put all of the Artifactory server configurations in a "rtServer" block.

(您应该将所有Artifactory服务器配置放在“ rtServer”块中。)

This defines a new Artifactoruy server for this build, and you can configure different Artifactory instances in different builds by configuring different names in the "def server = Artifactory.server('NAME')" line, and give it the proper configuration (repository names, paths, etc).

(这为此构建定义了一个新的Artifactoruy服务器,您可以通过在“ def server = Artifactory.server('NAME')”行中配置不同的名称来配置不同构建中的不同Artifactory实例,并为其进行适当的配置(存储库名称) ,路径等)。)

You can see this link for more information - https://www.jfrog.com/confluence/display/RTF/Declarative+Pipeline+Syntax#DeclarativePipelineSyntax-CreatinganArtifactoryServerInstance

(您可以查看此链接以获取更多信息-https://www.jfrog.com/confluence/display/RTF/Declarative+Pipeline+Syntax#DeclarativePipelineSyntax-CreatinganArtifactoryServerInstance)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...