Skip to content

Commit

Permalink
perf: add trigger deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Aug 5, 2024
1 parent 002c531 commit 69cc0e4
Showing 1 changed file with 74 additions and 63 deletions.
137 changes: 74 additions & 63 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,25 @@ def runShellCommand(script, int retries = 1) {
}



def buildImage(appName, appVersion, String type='CE') {
// Type EE, CE, MID, EE-MID
echo "Building ${appName}:${appVersion}"
echo "Type: ${type}"
echo "env: ${env}"
return

def appBuildOption = [
"core-xpack": [
"image": "xpack",
"dependBy": ["jumpserver"]
],
"jumpserver": [
"image": "core"
"image": "core",
],
"lina": [
"dependBy": ["docker-web"]
],
"luna": [
"beforeSh": "rm -rf dist luna"
"beforeSh": "rm -rf dist luna",
"dependBy": ["docker-web"]
],
"razor": [
"buildArgs": "-f docker/Dockerfile"
Expand All @@ -102,6 +102,18 @@ def buildImage(appName, appVersion, String type='CE') {
"image": "web"
]
]

// env.repo 是触发构建的仓库,如果不为空,只构建该仓库
// 但是如果构建的仓库依赖其他仓库,也需要构建依赖的仓库
// 比如说 env.repo = lina, 那么 docker-web 也需要构建
def depsBy = appBuildOption[env.repo]?.dependBy ?: []
def wasDepond = depsBy.contains(appName)

if (env.repo && (env.repo !== appName || !wasDepond)) {
echo "Skip ${appName} build, tigger is ${env.repo}, only deposBy ${depsBy}"
return
}

def buildArgs = getDefaultBuildArgs()
def passArgs = getDefaultPassArgs()
buildArgs += " ${passArgs}"
Expand Down Expand Up @@ -178,69 +190,68 @@ pipeline {
env.PIP_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple"
env.MAVEN_MIRROR="https://maven.aliyun.com/repository/public"
env.APK_MIRROR="mirrors.tuna.tsinghua.edu.cn"
env.repo = params.repo

env.each { key, value ->
println "${key} = ${value}"
sh "env"
}
}
}
stage('Checkout') {
steps {
script {
ALL_APPS.each { app ->
dir(app) {
if (app == env.repo || env.repo == '') {
git url: "[email protected]:jumpserver/${app}.git", branch: "${env.branch}"
}
}
}
}
}
}
stage('Build pre apps') {
steps {
script {
def ceStages = MID_APPS.collectEntries{ app ->
["Build ${app}": {
stage("Build ${app}") {
dir(app) {
script {
def type = "MID"
if (app == "core-xpack") {
type = "EE-MID"
}
buildImage(app, env.release_version, type)
}
}
}
}]
}
parallel ceStages
}
}
}
stage('Build Apps') {
steps {
script {
def buildStages = BUILD_APPS.collectEntries{ app ->
["Build ${app}": {
stage("Build ${app}") {
dir(app) {
script {
if (app in CE_APPS) {
buildImage(app, env.release_version, "CE")
}
buildImage(app, env.release_version, "EE")
}
}
}
}]
}
parallel buildStages
}
}
}
// stage('Checkout') {
// steps {
// script {
// ALL_APPS.each { app ->
// dir(app) {
// if (app == env.repo || env.repo == '') {
// git url: "[email protected]:jumpserver/${app}.git", branch: "${env.branch}"
// }
// }
// }
// }
// }
// }
// stage('Build pre apps') {
// steps {
// script {
// def ceStages = MID_APPS.collectEntries{ app ->
// ["Build ${app}": {
// stage("Build ${app}") {
// dir(app) {
// script {
// def type = "MID"
// if (app == "core-xpack") {
// type = "EE-MID"
// }
// buildImage(app, env.release_version, type)
// }
// }
// }
// }]
// }
// parallel ceStages
// }
// }
// }
// stage('Build Apps') {
// steps {
// script {
// def buildStages = BUILD_APPS.collectEntries{ app ->
// ["Build ${app}": {
// stage("Build ${app}") {
// dir(app) {
// script {
// if (app in CE_APPS) {
// buildImage(app, env.release_version, "CE")
// }
// buildImage(app, env.release_version, "EE")
// }
// }
// }
// }]
// }
// parallel buildStages
// }
// }
// }
stage('Restart') {
steps {
script {
Expand Down

0 comments on commit 69cc0e4

Please sign in to comment.