-
Notifications
You must be signed in to change notification settings - Fork 501
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automated cherry pick of #1237: put release jenkinsfile from jenkins …
…into repo (#1318)
- Loading branch information
Showing
4 changed files
with
244 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ def getChangeLogText() { | |
def call(BUILD_BRANCH, CREDENTIALS_ID, CODECOV_CREDENTIALS_ID) { | ||
|
||
def GITHASH | ||
def CODECOV_TOKEN | ||
def UCLOUD_OSS_URL = "http://pingcap-dev.hk.ufileos.com" | ||
def BUILD_URL = "[email protected]:pingcap/tidb-operator.git" | ||
def PROJECT_DIR = "go/src/github.com/pingcap/tidb-operator" | ||
|
@@ -44,25 +45,29 @@ def call(BUILD_BRANCH, CREDENTIALS_ID, CODECOV_CREDENTIALS_ID) { | |
|
||
GITHASH = sh(returnStdout: true, script: "git rev-parse HEAD").trim() | ||
withCredentials([string(credentialsId: "${CODECOV_CREDENTIALS_ID}", variable: 'codecovToken')]) { | ||
sh """ | ||
export GOPATH=${WORKSPACE}/go | ||
export PATH=${WORKSPACE}/go/bin:\$PATH | ||
if ! hash hg 2>/dev/null; then | ||
sudo yum install -y mercurial | ||
fi | ||
hg --version | ||
make check-setup | ||
make check | ||
if [ ${BUILD_BRANCH} == "master" ] | ||
then | ||
make test GO_COVER=y | ||
curl -s https://codecov.io/bash | bash -s - -t ${codecovToken} || echo'Codecov did not collect coverage reports' | ||
else | ||
make test | ||
fi | ||
make | ||
make e2e-build | ||
""" | ||
CODECOV_TOKEN = codecovToken | ||
} | ||
|
||
ansiColor('xterm') { | ||
sh """ | ||
export GOPATH=${WORKSPACE}/go | ||
export PATH=${WORKSPACE}/go/bin:\$PATH | ||
if ! hash hg 2>/dev/null; then | ||
sudo yum install -y mercurial | ||
fi | ||
hg --version | ||
make check-setup | ||
make check | ||
if [ ${BUILD_BRANCH} == "master" ] | ||
then | ||
make test GO_COVER=y | ||
curl -s https://codecov.io/bash | bash -s - -t ${CODECOV_TOKEN} || echo'Codecov did not collect coverage reports' | ||
else | ||
make test | ||
fi | ||
make | ||
make e2e-build | ||
""" | ||
} | ||
} | ||
} | ||
|
@@ -164,9 +169,9 @@ def call(BUILD_BRANCH, CREDENTIALS_ID, CODECOV_CREDENTIALS_ID) { | |
stage('Summary') { | ||
def CHANGELOG = getChangeLogText() | ||
def duration = ((System.currentTimeMillis() - currentBuild.startTimeInMillis) / 1000 / 60).setScale(2, BigDecimal.ROUND_HALF_UP) | ||
def slackmsg = "[#${ghprbPullId}: ${ghprbPullTitle}]" + "\n" + | ||
"${ghprbPullLink}" + "\n" + | ||
"${ghprbPullDescription}" + "\n" + | ||
def slackmsg = "[#${env.ghprbPullId}: ${env.ghprbPullTitle}]" + "\n" + | ||
"${env.ghprbPullLink}" + "\n" + | ||
"${env.ghprbPullDescription}" + "\n" + | ||
"Integration Common Test Result: `${currentBuild.result}`" + "\n" + | ||
"Elapsed Time: `${duration} mins` " + "\n" + | ||
"${CHANGELOG}" + "\n" + | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,108 @@ | ||
def call(BUILD_BRANCH, RELEASE_TAG) { | ||
|
||
env.GOPATH = "/go" | ||
env.GOROOT = "/usr/local/go" | ||
env.PATH = "${env.GOROOT}/bin:${env.GOPATH}/bin:/bin:${env.PATH}:/home/jenkins/bin" | ||
|
||
def GITHASH | ||
def TKCTL_CLI_PACKAGE = "tkctl-${GOOS}-${GOARCH}-${RELEASE_TAG}" | ||
|
||
catchError { | ||
node('k8s_centos7_build') { | ||
def WORKSPACE = pwd() | ||
|
||
dir("${WORKSPACE}/operator"){ | ||
stage('Build and release CLI to qiniu'){ | ||
checkout([$class: 'GitSCM', branches: [[name: "${BUILD_BRANCH}"]], userRemoteConfigs:[[url: "${BUILD_URL}", credentialsId: "${CREDENTIALS_ID}"]]]) | ||
GITHASH = sh(returnStdout: true, script: "git rev-parse HEAD").trim() | ||
def GOARCH = "amd64" | ||
["linux", "darwin", "windows"].each { | ||
sh """ | ||
GOOS=${it} GOARCH=${GOARCH} make cli | ||
tar -zcf ${TKCTL_CLI_PACKAGE}.tgz tkctl | ||
sha256sum ${TKCTL_CLI_PACKAGE}.tgz > ${TKCTL_CLI_PACKAGE}.sha256 | ||
upload.py ${TKCTL_CLI_PACKAGE}.tgz ${TKCTL_CLI_PACKAGE}.tgz | ||
upload.py ${TKCTL_CLI_PACKAGE}.sha256 ${TKCTL_CLI_PACKAGE}.sha256 | ||
""" | ||
} | ||
} | ||
|
||
stage('Build and push debug images'){ | ||
withDockerServer([uri: "${env.DOCKER_HOST}"]) { | ||
DOCKER_REGISTRY="" make debug-docker-push | ||
DOCKER_REGISTRY="uhub.service.ucloud.cn" make debug-docker-push | ||
} | ||
} | ||
} | ||
} | ||
currentBuild.result = "SUCCESS" | ||
} | ||
stage('Summary') { | ||
echo("echo summary info ########") | ||
def DURATION = ((System.currentTimeMillis() - currentBuild.startTimeInMillis) / 1000 / 60).setScale(2, BigDecimal.ROUND_HALF_UP) | ||
def slackmsg = "[${env.JOB_NAME.replaceAll('%2F','/')}-${env.BUILD_NUMBER}] `${currentBuild.result}`" + "\n" + | ||
"Elapsed Time: `${DURATION}` Mins" + "\n" + | ||
"tidb-operator Branch: `${BUILD_BRANCH}`, Githash: `${GITHASH.take(7)}`" + "\n" + | ||
"Display URL:" + "\n" + | ||
"${env.RUN_DISPLAY_URL}" | ||
|
||
if(currentBuild.result != "SUCCESS"){ | ||
slackSend channel: '#cloud_jenkins', color: 'danger', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}" | ||
} else { | ||
slackmsg = "${slackmsg}" + "\n" + | ||
"tkctl cli tool build and debug image build failed for BRANCH:${BUILD_BRANCH} and TAG:${RELEASE_TAG}`" | ||
slackSend channel: '#cloud_jenkins', color: 'good', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}" | ||
} | ||
} | ||
def call(BUILD_BRANCH, RELEASE_TAG, CREDENTIALS_ID) { | ||
def GITHASH | ||
def TKCTL_CLI_PACKAGE | ||
def GOARCH = "amd64" | ||
def OS_LIST = ["linux", "darwin", "windows"] | ||
def DEBUG_LIST = ["debug-launcher", "tidb-control", "tidb-debug"] | ||
def BUILD_URL = "[email protected]:pingcap/tidb-operator.git" | ||
def PROJECT_DIR = "go/src/github.com/pingcap/tidb-operator" | ||
|
||
catchError { | ||
node('build_go1130_memvolume') { | ||
container("golang") { | ||
def WORKSPACE = pwd() | ||
dir("${PROJECT_DIR}") { | ||
stage('build tkcli') { | ||
checkout([$class: 'GitSCM', branches: [[name: "${BUILD_BRANCH}"]], userRemoteConfigs: [[url: "${BUILD_URL}", credentialsId: "${CREDENTIALS_ID}"]]]) | ||
checkout changelog: false, | ||
poll: false, | ||
scm: [ | ||
$class: 'GitSCM', | ||
branches: [[name: "${BUILD_BRANCH}"]], | ||
doGenerateSubmoduleConfigurations: false, | ||
extensions: [], | ||
submoduleCfg: [], | ||
userRemoteConfigs: [[ | ||
credentialsId: "${CREDENTIALS_ID}", | ||
refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*:refs/remotes/origin/pr/*', | ||
url: "${BUILD_URL}", | ||
]] | ||
] | ||
|
||
GITHASH = sh(returnStdout: true, script: "git rev-parse HEAD").trim() | ||
sh "make debug-build" | ||
|
||
OS_LIST.each { | ||
TKCTL_CLI_PACKAGE = "tkctl-${it}-${GOARCH}-${RELEASE_TAG}" | ||
sh """ | ||
GOOS=${it} GOARCH=${GOARCH} make cli | ||
tar -zcf ${TKCTL_CLI_PACKAGE}.tgz tkctl | ||
sha256sum ${TKCTL_CLI_PACKAGE}.tgz > ${TKCTL_CLI_PACKAGE}.sha256 | ||
""" | ||
} | ||
} | ||
} | ||
|
||
stash excludes: "${PROJECT_DIR}/vendor/**", includes: "${PROJECT_DIR}/**", name: "tidb-operator" | ||
} | ||
} | ||
node('delivery') { | ||
container("delivery") { | ||
def WORKSPACE = pwd() | ||
sh "chown -R jenkins:jenkins ./" | ||
deleteDir() | ||
unstash 'tidb-operator' | ||
|
||
dir("${PROJECT_DIR}") { | ||
stage('Publish tkcli') { | ||
OS_LIST.each { | ||
TKCTL_CLI_PACKAGE = "tkctl-${it}-${GOARCH}-${RELEASE_TAG}" | ||
sh """ | ||
upload.py ${TKCTL_CLI_PACKAGE}.tgz ${TKCTL_CLI_PACKAGE}.tgz | ||
upload.py ${TKCTL_CLI_PACKAGE}.sha256 ${TKCTL_CLI_PACKAGE}.sha256 | ||
""" | ||
} | ||
|
||
stage('Push utility docker images') { | ||
withDockerServer([uri: "${env.DOCKER_HOST}"]) { | ||
DEBUG_LIST.each { | ||
docker.build("uhub.service.ucloud.cn/pingcap/${it}:${RELEASE_TAG}", "misc/images/${it}").push() | ||
docker.build("pingcap/${it}:${RELEASE_TAG}", "misc/images/${it}").push() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
currentBuild.result = "SUCCESS" | ||
} | ||
stage('Summary') { | ||
echo("echo summary info ########") | ||
def DURATION = ((System.currentTimeMillis() - currentBuild.startTimeInMillis) / 1000 / 60).setScale(2, BigDecimal.ROUND_HALF_UP) | ||
def slackmsg = "[${env.JOB_NAME.replaceAll('%2F','/')}-${env.BUILD_NUMBER}] `${currentBuild.result}`" + "\n" + | ||
"Elapsed Time: `${DURATION}` Mins" + "\n" + | ||
"tidb-operator Branch: `${BUILD_BRANCH}`, Githash: `${GITHASH.take(7)}`" + "\n" + | ||
"Display URL:" + "\n" + | ||
"${env.RUN_DISPLAY_URL}" | ||
|
||
if(currentBuild.result != "SUCCESS"){ | ||
slackSend channel: '#cloud_jenkins', color: 'danger', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}" | ||
return | ||
} | ||
|
||
DEBUG_LIST.each{ | ||
slackmsg = "${slackmsg}" + "\n" + | ||
"${it} Docker Image: Docker Image: `pingcap/${it}:${RELEASE_TAG}`" + "\n" + | ||
"${it} Docker Image: Docker Image: `uhub.ucloud.cn/pingcap/${it}:${RELEASE_TAG}`" | ||
} | ||
|
||
OS_LIST.each{ | ||
slackmsg = "${slackmsg}" + "\n" + | ||
"tkctl ${it} binary Download URL: https://download.pingcap.org/tkctl-${it}-${GOARCH}-${RELEASE_TAG}.tgz" | ||
} | ||
slackSend channel: '#cloud_jenkins', color: 'good', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}" | ||
} | ||
} | ||
|
||
return this |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.