实例:Jenkinsfile
最后更新于:2022-04-02 02:58:30
[TOC]
## 实例
多个 git 仓库的编译
Jenkinsfile
```
pipeline {
agent {
// 选择标签带国产化的服务器节点
label 'gch'
}
stages {
stage("build:im_server"){
steps{
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/master']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'linux_server_gch_build']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: '1b4dcb8e-2eb7-4bb4-a9e0-204e9179b086', url: 'http://192.168.0.40/bigant/server/im_server_standard.git']]
])
dir("linux_server_gch_build"){
sh """
chmod +x *.sh
case $SYSTEM in
*飞腾*)
./build.sh release "uosv20aarch64"
;;
*龙芯*)
./build.sh release "uosv20mips64"
;;
*x86*)
./build.sh release "uosv20x64"
;;
esac
"""
}
}
}
stage('build') {
parallel {
stage("build:www"){
steps{
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/master_no_saas']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'www']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: '1b4dcb8e-2eb7-4bb4-a9e0-204e9179b086', url: 'http://192.168.0.40/bigant/web/ant_universal.git']]
])
}
}
stage("build:antbiz"){
steps{
checkout([
$class: 'GitSCM',
branches: [[name: 'refs/heads/new_master']],
extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'linux_go_gch_build']],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: '1b4dcb8e-2eb7-4bb4-a9e0-204e9179b086', url: 'http://192.168.0.40/php/go_member_api.git']]
])
// 编译 go
dir("linux_go_gch_build"){
sh "chmod +x *.sh && ./build_for_gch.sh ${SYSTEM}"
}
}
}
}
}
stage("package"){
steps{
dir("rpmbuild"){
sh "chmod +x *.sh && ./deploy_pipe.sh ${SYSTEM} ${DATA_PATH}"
}
}
}
}
}
```
';