Skip to content

Commit

Permalink
refactor(jenkins/pipelines,pipelines): use the new dockerfile url loc…
Browse files Browse the repository at this point in the history
…ation (#2960)

Reverts #2959
  • Loading branch information
wuhuizuo committed May 11, 2024
1 parent 671fb03 commit d0da054
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 38 deletions.
39 changes: 15 additions & 24 deletions jenkins/pipelines/cd/atom-jobs/docker-common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ if (PRODUCT == "tics" || PRODUCT == "tiflash" ) {
}
}

+ def additionalArgs = ""
+ if (params.BASE_IMG) {
+ additionalArgs += " --build-arg BASE_IMG=${params.BASE_IMG}"
+ }

// 定义非默认的构建镜像脚本
buildImgagesh = [:]

Expand All @@ -97,43 +102,31 @@ cd monitoring/
mv Dockerfile Dockerfile.bak || true
curl -C - --retry 5 --retry-delay 6 --retry-max-time 60 -o Dockerfile ${DOCKERFILE}
cat Dockerfile
docker build --pull -t ${imagePlaceHolder} . --build-arg BASE_IMG=${params.BASE_IMG}
"""

buildImgagesh["tics"] = """
mv Dockerfile Dockerfile.bak || true
curl -C - --retry 5 --retry-delay 6 --retry-max-time 60 -o Dockerfile ${DOCKERFILE}
cat Dockerfile
if [[ "${RELEASE_TAG}" == "" ]]; then
# No release tag, the image may be used in testings
docker build --pull -t ${imagePlaceHolder} . --build-arg INSTALL_MYSQL=1 --build-arg BASE_IMG=${params.BASE_IMG}
else
# Release tag provided, do not install test utils
docker build --pull -t ${imagePlaceHolder} . --build-arg INSTALL_MYSQL=0 --build-arg BASE_IMG=${params.BASE_IMG}
fi
docker build --pull -t ${imagePlaceHolder} . ${additionalArgs}
"""

buildImgagesh["tiflash"] = """
mv Dockerfile Dockerfile.bak || true
curl -C - --retry 5 --retry-delay 6 --retry-max-time 60 -o Dockerfile ${DOCKERFILE}
cat Dockerfile
additional_args=''
if [[ "${RELEASE_TAG}" == "" ]]; then
# No release tag, the image may be used in testings
docker build --pull -t ${imagePlaceHolder} . --build-arg INSTALL_MYSQL=1 --build-arg BASE_IMG=${params.BASE_IMG}
additional_args="\$additional_args --build-arg INSTALL_MYSQL=1"
else
# Release tag provided, do not install test utils
docker build --pull -t ${imagePlaceHolder} . --build-arg INSTALL_MYSQL=0 --build-arg BASE_IMG=${params.BASE_IMG}
additional_args="\$additional_args --build-arg INSTALL_MYSQL=0"
fi
docker build --pull -t ${imagePlaceHolder} . ${additionalArgs}
"""

buildImgagesh["tics"] = buildImgagesh["tiflash"]

buildImgagesh["monitoring"] = """
docker build --pull -t ${imagePlaceHolder} . --build-arg BASE_IMG=${params.BASE_IMG}
"""
buildImgagesh["monitoring"] = "docker build --pull -t ${imagePlaceHolder} . ${additionalArgs}"

buildImgagesh["tiem"] = """
cp /usr/local/go/lib/time/zoneinfo.zip ./
docker build --pull -t ${imagePlaceHolder} . --build-arg BASE_IMG=${params.BASE_IMG}
docker build --pull -t ${imagePlaceHolder} . ${additionalArgs}
"""

buildImgagesh["tidb"] = """
Expand All @@ -151,11 +144,9 @@ fi
mv Dockerfile Dockerfile.bak || true
curl -C - --retry 5 --retry-delay 6 --retry-max-time 60 -o Dockerfile ${DOCKERFILE}
cat Dockerfile
docker build --pull -t ${imagePlaceHolder} . --build-arg BASE_IMG=${params.BASE_IMG}
docker build --pull -t ${imagePlaceHolder} . ${additionalArgs}
"""



def build_image() {
// 如果构建脚本被定义了,使用定义的构建脚本
if (buildImgagesh.containsKey(PRODUCT)) {
Expand All @@ -170,7 +161,7 @@ def build_image() {
mv Dockerfile Dockerfile.bak || true
curl -C - --retry 5 --retry-delay 6 --retry-max-time 60 -o Dockerfile ${DOCKERFILE}
cat Dockerfile
docker build --pull -t ${imagePlaceHolder} . --build-arg BASE_IMG=${params.BASE_IMG}
docker build --pull -t ${imagePlaceHolder} . ${additionalArgs}
"""
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def buildBin={
def buildDocker={
sh 'printenv HUB_PSW | docker login -u $HUB_USR --password-stdin hub.pingcap.net'
sh """
curl --fail --retry 3 -o Dockerfile https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/tiflash.Dockerfile
curl --fail --retry 3 -o Dockerfile https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/tiflash.Dockerfile
curl --fail --retry 3 -o tiflash.tar.gz ${getBinDownloadURL()}
tar -xzvf tiflash.tar.gz
rm -f tiflash.tar.gz
Expand Down
8 changes: 1 addition & 7 deletions jenkins/pipelines/cd/dev-build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,11 @@ def get_dockerfile_url={arch ->
if (params.ProductDockerfile){
return params.ProductDockerfile
}
if (params.ProductBaseImg){
if (Product == "tidb" && Edition == "enterprise") {
fileName = fileName + '-enterprise'
}
return "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/${fileName}.Dockerfile"
}
if (Version>='v6.6.0'){
if (Product == "tidb" && Edition == "enterprise") {
fileName = fileName + '-enterprise'
}
return "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/${fileName}.Dockerfile"
return "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/${fileName}.Dockerfile"
}else{
if (Product == "tidb" && Edition == "enterprise") {
fileName = "enterprise/${Product}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def get_dockerfile_url(arch, repo, isDebug){
}
def fileName = Product
if (RELEASE_TAG >='v6.6.0'){
return "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/${fileName}.Dockerfile"
return "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/${fileName}.Dockerfile"
}else{
if (isDebug){
return "https://raw.githubusercontent.com/PingCAP-QE/ci/main/jenkins/Dockerfile/release/debug-image/${fileName}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_dockerfile_url(product, is_enterprise, is_debug){
if (is_debug) {
fileName = fileName + "-debug"
}
return "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/${fileName}.Dockerfile"
return "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/${fileName}.Dockerfile"
}

def get_image_str_for_community(product, arch, is_failpoint, is_debug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_image_str_for_enterprise(product, arch, tag) {
def build_tidb_enterprise_image(product, sha1, plugin_hash, arch) {
def binary = "builds/pingcap/${product}/optimization/${RELEASE_TAG}/${sha1}/centos7/${product}-linux-${arch}-enterprise.tar.gz"
def plugin_binary = "builds/pingcap/enterprise-plugin/optimization/${RELEASE_TAG}/${plugin_hash}/centos7/enterprise-plugin-linux-${arch}-enterprise.tar.gz"
def dockerfile = "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/${product}-enterprise.Dockerfile"
def dockerfile = "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/${product}-enterprise.Dockerfile"
def image = get_image_str_for_enterprise("tidb", arch, RELEASE_TAG)
def paramsDocker = [
string(name: "ARCH", value: arch),
Expand All @@ -101,7 +101,7 @@ def build_enterprise_image(product, sha1, arch) {
if (product == "tidb-lightning") {
binary = "builds/pingcap/br/optimization/${RELEASE_TAG}/${sha1}/centos7/br-linux-${arch}-enterprise.tar.gz"
}
def dockerfile = "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/${product}.Dockerfile"
def dockerfile = "https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/${product}.Dockerfile"
def repo = product
def image = get_image_str_for_enterprise(product, arch, RELEASE_TAG)

Expand Down
2 changes: 1 addition & 1 deletion pipelines/pingcap/tidb/latest/merged_tiflash_test.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pipeline {
}
dir("build-docker-image") {
sh label: 'generate dockerfile', script: """
curl -o tidb.Dockerfile https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/tidb.Dockerfile
curl -o tidb.Dockerfile https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/tidb.Dockerfile
cat tidb.Dockerfile
cp ../tidb/bin/tidb-server tidb-server
./tidb-server -V
Expand Down
2 changes: 1 addition & 1 deletion pipelines/pingcap/tidb/latest/pull_tiflash_test.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pipeline {
}
dir("build-docker-image") {
sh label: 'generate dockerfile', script: """
curl -o tidb.Dockerfile https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/tidb.Dockerfile
curl -o tidb.Dockerfile https://raw.githubusercontent.com/PingCAP-QE/artifacts/main/dockerfiles/products/tidb.Dockerfile
cat tidb.Dockerfile
cp ../tidb/bin/tidb-server tidb-server
./tidb-server -V
Expand Down

0 comments on commit d0da054

Please sign in to comment.