Skip to content

Commit cd4cbcd

Browse files
committed
curl failure check
1 parent c0ea07c commit cd4cbcd

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

dev/publish_release.sh

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ for var in GPG_PASSPHRASE ASF_USERID ASF_PASSWORD; do
3838
done
3939

4040
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512m"
41+
RED='\033[0;31m'
42+
NC='\033[0m' # No Color
4143

4244
RELEASE_VERSION="$1"
4345
GIT_TAG="$2"
@@ -47,6 +49,24 @@ PROJECT_OPTIONS="-pl !zeppelin-distribution"
4749
NEXUS_STAGING="https://repository.apache.org/service/local/staging"
4850
NEXUS_PROFILE="153446d1ac37c4"
4951

52+
function cleanup() {
53+
echo "Remove working directory and maven local repository"
54+
rm -rf ${WORKING_DIR}
55+
rm -rf ${tmp_repo}
56+
}
57+
58+
function curl_error() {
59+
ret=${1}
60+
if [[ $ret -ne 0 ]]; then
61+
echo "curl response code is: ($ret)"
62+
echo "See https://curl.haxx.se/libcurl/c/libcurl-errors.html to know the detailed cause of error."
63+
echo -e "${RED}Failed to publish maven artifact to staging repository."
64+
echo -e "IMPORTANT: You will have to re-run publish_release.sh to complete maven artifact publish.${NC}"
65+
cleanup
66+
exit 1
67+
fi
68+
}
69+
5070
function publish_to_maven() {
5171
cd "${WORKING_DIR}/zeppelin"
5272

@@ -60,6 +80,8 @@ function publish_to_maven() {
6080
out="$(curl -X POST -d "${repo_request}" -u "${ASF_USERID}:${ASF_PASSWORD}" \
6181
-H 'Content-Type:application/xml' -v \
6282
"${NEXUS_STAGING}/profiles/${NEXUS_PROFILE}/start")"
83+
create_ret=$?
84+
curl_error $create_ret
6385
staged_repo_id="$(echo "${out}" | sed -e 's/.*\(orgapachezeppelin-[0-9]\{4\}\).*/\1/')"
6486
echo "Created Nexus staging repository: ${staged_repo_id}"
6587

@@ -94,20 +116,23 @@ function publish_to_maven() {
94116
dest_url="${nexus_upload}/org/apache/zeppelin/$file_short"
95117
echo " Uploading ${file_short}"
96118
curl -u "${ASF_USERID}:${ASF_PASSWORD}" --upload-file "${file_short}" "${dest_url}"
119+
upload_ret=$?
120+
curl_error $upload_ret
97121
done
98122

99123
echo "Closing nexus staging repository"
100124
repo_request="<promoteRequest><data><stagedRepositoryId>${staged_repo_id}</stagedRepositoryId><description>Apache Zeppelin ${RELEASE_VERSION}</description></data></promoteRequest>"
101125
out="$(curl -X POST -d "${repo_request}" -u "${ASF_USERID}:${ASF_PASSWORD}" \
102126
-H 'Content-Type:application/xml' -v \
103127
"${NEXUS_STAGING}}/profiles/${NEXUS_PROFILE}/finish")"
128+
close_ret=$?
129+
curl_error $close_ret
104130
echo "Closed Nexus staging repository: ${staged_repo_id}"
105131
popd
106-
rm -rf "${tmp_repo}"
132+
echo "Complete publishing maven artifacts to apache staging repository"
133+
echo "Once release candidate pass the vote, do not forget to hit the release button in https://repository.apache.org"
107134
}
108135

109136
git_clone
110137
publish_to_maven
111-
112-
# remove working directory
113-
rm -rf "${WORKING_DIR}/zeppelin"
138+
cleanup

0 commit comments

Comments
 (0)