Skip to content

Commit

Permalink
cherry pick #4562 to release-1.3 (#4563)
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>

Co-authored-by: Shiori <[email protected]>
  • Loading branch information
ti-srebot and KanShiori authored Jun 22, 2022
1 parent 2f12ca1 commit bcc75b0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 73 deletions.
7 changes: 4 additions & 3 deletions ci/deploy_tidb_operator_staging.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ features:

def call(BUILD_BRANCH) {
def GITHASH
def UCLOUD_OSS_URL = "http://pingcap-dev.hk.ufileos.com"
def FILE_SERVER_URL = "http://fileserver.pingcap.net"
def FILE_BASE_DIR = "pingcap/tidb-operator"

catchError {
node('delivery') {
Expand All @@ -49,8 +50,8 @@ def call(BUILD_BRANCH) {

dir("${WORKSPACE}/operator-staging") {
stage('Download tidb-operator binary') {
GITHASH = sh(returnStdout: true, script: "curl ${UCLOUD_OSS_URL}/refs/pingcap/operator/${BUILD_BRANCH}/centos7/sha1").trim()
sh "curl ${UCLOUD_OSS_URL}/builds/pingcap/operator/${GITHASH}/centos7/tidb-operator.tar.gz | tar xz"
GITHASH = sh(returnStdout: true, script: "curl ${FILE_SERVER_URL}/download/${FILE_BASE_DIR}/refs/${BUILD_BRANCH}/sha1").trim()
sh "curl ${FILE_SERVER_URL}/download/${FILE_BASE_DIR}/builds/${GITHASH}/tidb-operator.tar.gz | tar xz"
}
stage('Push tidb-operator Docker Image to Harbor') {
docker.withRegistry("https://hub.pingcap.net", "harbor-pingcap") {
Expand Down
17 changes: 5 additions & 12 deletions ci/pull_e2e_kind.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -400,18 +400,11 @@ try {
dir("${PROJECT_DIR}") {
unstash 'tidb-operator'
stage('upload tidb-operator binaries and charts'){
withCredentials([
string(credentialsId: 'UCLOUD_PUBLIC_KEY', variable: 'UCLOUD_PUBLIC_KEY'),
string(credentialsId: 'UCLOUD_PRIVATE_KEY', variable: 'UCLOUD_PRIVATE_KEY'),
]) {
sh """
export UCLOUD_UFILE_PROXY_HOST=pingcap-dev.hk.ufileos.com
export UCLOUD_UFILE_BUCKET=pingcap-dev
export BUILD_BRANCH=${GIT_REF}
export GITHASH=${GITHASH}
./ci/upload-binaries-charts.sh
"""
}
sh """
export BUILD_BRANCH=${GIT_REF}
export GITHASH=${GITHASH}
./ci/upload-binaries-charts.sh
"""
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions ci/pull_e2e_release.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,11 @@ try {
dir("${PROJECT_DIR}") {
unstash 'tidb-operator'
stage('upload tidb-operator binaries and charts'){
withCredentials([
string(credentialsId: 'UCLOUD_PUBLIC_KEY', variable: 'UCLOUD_PUBLIC_KEY'),
string(credentialsId: 'UCLOUD_PRIVATE_KEY', variable: 'UCLOUD_PRIVATE_KEY'),
]) {
sh """
export UCLOUD_UFILE_PROXY_HOST=pingcap-dev.hk.ufileos.com
export UCLOUD_UFILE_BUCKET=pingcap-dev
export BUILD_BRANCH=${GIT_REF}
export GITHASH=${GITHASH}
./ci/upload-binaries-charts.sh
"""
}
sh """
export BUILD_BRANCH=${GIT_REF}
export GITHASH=${GITHASH}
./ci/upload-binaries-charts.sh
"""
}
}
}
Expand Down
17 changes: 5 additions & 12 deletions ci/release-nightly.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,11 @@ try {
}

stage('Upload binaries and charts'){
withCredentials([
string(credentialsId: 'UCLOUD_PUBLIC_KEY', variable: 'UCLOUD_PUBLIC_KEY'),
string(credentialsId: 'UCLOUD_PRIVATE_KEY', variable: 'UCLOUD_PRIVATE_KEY'),
]) {
sh """
export UCLOUD_UFILE_PROXY_HOST=pingcap-dev.hk.ufileos.com
export UCLOUD_UFILE_BUCKET=pingcap-dev
export BUILD_BRANCH=${GIT_REF}
export GITHASH=${GITHASH}
./ci/upload-binaries-charts.sh
"""
}
sh """
export BUILD_BRANCH=${GIT_REF}
export GITHASH=${GITHASH}
./ci/upload-binaries-charts.sh
"""
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions ci/release_tidb_operator_binary_and_image.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ def call(BUILD_BRANCH, RELEASE_TAG, CREDENTIALS_ID, CHART_ITEMS) {
def GITHASH
def ACCESS_KEY
def SECRET_KEY
def UCLOUD_OSS_URL = "http://pingcap-dev.hk.ufileos.com"
def FILE_SERVER_URL = "http://fileserver.pingcap.net"
def FILE_BASE_DIR = "pingcap/tidb-operator"

catchError {
def delivery_pod_label = "${JOB_NAME}-${BUILD_NUMBER}"
Expand Down Expand Up @@ -43,9 +44,9 @@ def call(BUILD_BRANCH, RELEASE_TAG, CREDENTIALS_ID, CHART_ITEMS) {

dir("${WORKSPACE}/operator") {
stage('Download tidb-operator binary'){
GITHASH = sh(returnStdout: true, script: "curl ${UCLOUD_OSS_URL}/refs/pingcap/operator/${BUILD_BRANCH}/centos7/sha1").trim()
GITHASH = sh(returnStdout: true, script: "curl ${FILE_SERVER_URL}/download/${FILE_BASE_DIR}/refs/${BUILD_BRANCH}/sha1").trim()
sh """
curl ${UCLOUD_OSS_URL}/builds/pingcap/operator/${GITHASH}/centos7/tidb-operator.tar.gz | tar xz
curl ${FILE_SERVER_URL}/download/${FILE_BASE_DIR}/builds/${GITHASH}/tidb-operator.tar.gz | tar xz
wget https://github.com/docker/buildx/releases/download/v0.8.0/buildx-v0.8.0.linux-amd64 -O /usr/bin/buildx
chmod +x /usr/bin/buildx
Expand Down
35 changes: 4 additions & 31 deletions ci/upload-binaries-charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,11 @@ cd $ROOT

source "${ROOT}/hack/lib.sh"

UCLOUD_PUBLIC_KEY=${UCLOUD_PUBLIC_KEY:-}
UCLOUD_PRIVATE_KEY=${UCLOUD_PRIVATE_KEY:-}
UCLOUD_UFILE_PROXY_HOST=${UCLOUD_UFILE_PROXY_HOST:-}
UCLOUD_UFILE_API_HOST=${UCLOUD_UFILE_API_HOST:-api.spark.ucloud.cn}
UCLOUD_UFILE_BUCKET=${UCLOUD_UFILE_BUCKET:-}
FILE_SERVER_URL=http://fileserver.pingcap.net
FILE_BASE_DIR=pingcap/tidb-operator
GITHASH=${GITHASH:-}
BUILD_BRANCH=${BUILD_BRANCH:-}

FILEMGR_URL="http://tools.ufile.ucloud.com.cn/filemgr-linux64.tar.gz"

if [ -z "$UCLOUD_PUBLIC_KEY" -o -z "$UCLOUD_PRIVATE_KEY" -o -z "$UCLOUD_UFILE_PROXY_HOST" ]; then
echo "error: UCLOUD_PUBLIC_KEY/UCLOUD_PUBLIC_KEY/UCLOUD_UFILE_PROXY_HOST are required"
exit 1
fi

if [ -z "$UCLOUD_UFILE_BUCKET" ]; then
echo "error: UCLOUD_UFILE_BUCKET is required"
exit 1
fi

if [ -z "$GITHASH" -o -z "$BUILD_BRANCH" ]; then
echo "error: GITHASH/BUILD_BRANCH are required"
exit 1
Expand All @@ -53,25 +38,13 @@ function upload() {

echo "info: create a temporary directory: $dir"

cat <<EOF > $dir/config.cfg
{
"public_key" : "${UCLOUD_PUBLIC_KEY}",
"private_key" : "${UCLOUD_PRIVATE_KEY}",
"proxy_host" : "${UCLOUD_UFILE_PROXY_HOST}",
"api_host" : "${UCLOUD_UFILE_API_HOST}"
}
EOF

echo "info: downloading filemgr from $FILEMGR_URL"
curl --retry 10 -L -s "$FILEMGR_URL" | tar --strip-components 1 -C $dir -xzvf -

echo "info: uploading charts and binaries"
tar -zcvf $dir/tidb-operator.tar.gz images/tidb-operator images/tidb-backup-manager charts
$dir/linux64/filemgr-linux64 --config $dir/config.cfg --action mput --bucket ${UCLOUD_UFILE_BUCKET} --nobar --key builds/pingcap/operator/${GITHASH}/centos7/tidb-operator.tar.gz --file $dir/tidb-operator.tar.gz
curl -F ${FILE_BASE_DIR}/builds/${GITHASH}/tidb-operator.tar.gz=@$dir/tidb-operator.tar.gz ${FILE_SERVER_URL}/upload

echo "info: update ref of branch '$BUILD_BRANCH'"
echo -n $GITHASH > $dir/sha1
$dir/linux64/filemgr-linux64 --config $dir/config.cfg --action mput --bucket ${UCLOUD_UFILE_BUCKET} --nobar --key refs/pingcap/operator/${BUILD_BRANCH}/centos7/sha1 --file $dir/sha1
curl -F ${FILE_BASE_DIR}/refs/${BUILD_BRANCH}/sha1=@$dir/sha1 ${FILE_SERVER_URL}/upload
}

# retry a few times until it succeeds, this can avoid temporary network flakes
Expand Down

0 comments on commit bcc75b0

Please sign in to comment.