jenkins - 将当前构建的工件复制到服务器位置的 Jenkins 管道脚本
问题描述
我想创建一个 Jenkins 作业,它执行以下操作:Git>Mvn build> 将 jar 复制到服务器的某个位置。
所以这可以使用一个工作或两个工作来完成?或者哪种是首选方式,管道是否优于创建 maven 作业?
我已经创建了这个管道脚本,但这不会将当前构建 jar 复制到服务器位置,它会复制以前的构建工件 jar。
node {
def mvnHome
stage('Preparation') { // for display purposes
// Get some code from a GitHub repository
git 'git@github.pie.ABC.com:abcdef/BoltRepo.git'
mvnHome = tool 'M2'
}
stage('Build') {
// Run the maven build
if (isUnix()) {
sh "'${mvnHome}/bin/mvn' -Dmaven.test.failure.ignore clean package"
} else {
bat(/"${mvnHome}binmvn" -Dmaven.test.failure.ignore clean package/)
}
}
stage('Results') {
archiveArtifacts 'target/*/BoltRepo*.jar'
}
stage('Deploy Artifact') {
copyArtifacts(
projectName: currentBuild.projectName,
filter: 'target/*/BoltRepo*.jar',
fingerprintArtifacts: true,
target: '/ngs/app/boltd/bolt/bolt_components/bolt_provision/test',
flatten: true )
}
}
What is the best way of achieving this.
解决方案
我以前没有使用过管道,但是我已经使用作业配置中“构建后操作”中的“ArtifactDeployer”完成了您想要的操作注意:您需要安装“Artifact Deployer Plug-in”
推荐阅读
- go - 如何在 go-gin 框架中验证 API 密钥?
- apache -
节和 ProxyPass 超越子位置 在阿帕奇 2.2 - java - 什么是局部变量?
- sql - 如何将字符串添加到列值但忽略空字段
- google-api - 如何使用自定义对象创建触发器在谷歌驱动器中创建一个新文件夹?
- r - RSelenium Chromedriver 超时
- javascript - Node JS比较2个嵌套数组数据
- github - 通过 Artifactory git 镜像克隆 github.com repo
- javascript - 计算 RCON 的数据包大小?
- java - 如何将数组添加到此循环中,以便存储数据