1 Star 0 Fork 22

george366/spring-cloud-wang

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Jenkinsfile-test 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
wangziyang 提交于 2022-06-24 11:15 . docker
def tag = "latest"
def harbor_url = "xxx:18080"
def harbor_project = "test"
def harbor_auth = "xxx"
node {
def selectProjectNames = "${name}".split(",")
def serverNames = "${server}".split(",")
stage('拉取代码'){
git branch: 'test', credentialsId: 'xxx', url: 'http://xxx33333/backend/xxx.git'
}
stage('安装 公共类'){
sh "mvn -f recharge-common clean install"
sh "mvn -f recharge-api clean install"
}
stage('编译 打包 上传镜像'){
for(int i=0;i<selectProjectNames.length;i++){
def projectInfo = selectProjectNames[i];
def currentProjectName = "${projectInfo}".split("@")[0]
def currentProjectPort = "${projectInfo}".split("@")[1]
sh "mvn -f ${currentProjectName} clean package dockerfile:build"
def imageName = "${currentProjectName}:${tag}"
sh "docker tag ${imageName} ${harbor_url}/${harbor_project}/${imageName}"
withCredentials([usernamePassword(credentialsId: "${harbor_auth}", passwordVariable: 'password', usernameVariable: 'username')]) {
sh "docker login -u ${username} -p ${password} ${harbor_url}"
sh "docker push ${harbor_url}/${harbor_project}/${imageName}"
sh "echo 镜像上传成功"
}
for(int j=0;j<serverNames.length;j++){
def serverName = serverNames[j];
sshPublisher(publishers: [sshPublisherDesc(configName: "${serverName}", transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: "/opt/jenkins_shell/deploy.sh $harbor_url $harbor_project $currentProjectName $tag $currentProjectPort", execTimeout: 1200000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: '')], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)])
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/george366/spring-cloud-wang.git
git@gitee.com:george366/spring-cloud-wang.git
george366
spring-cloud-wang
spring-cloud-wang
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385