@@ -38,7 +38,9 @@ RC_NAME=${RC_NAME:-rc2}
3838
3939M2_REPO=~ /.m2/repository
4040SPARK_REPO=$M2_REPO /org/apache/spark
41- NEXUS_REPOSITORY=https://repository.apache.org/service/local/staging/deploy/maven2
41+ NEXUS_ROOT=https://repository.apache.org/service/local/staging
42+ NEXUS_UPLOAD=$NEXUS_ROOT /deploy/maven2
43+ NEXUS_PROFILE=d63f592e7eac0 # Profile for Spark staging uploads
4244
4345if [ -z " $JAVA_HOME " ]; then
4446 echo " Error: JAVA_HOME is not set, cannot proceed."
@@ -78,10 +80,16 @@ if [[ ! "$@" =~ --package-only ]]; then
7880 git push origin $GIT_TAG
7981 git push origin HEAD:$GIT_BRANCH
8082 git checkout -f $GIT_TAG
81-
82- # TODO: Programatically create and close Maven repo:
83- # curl -X POST -d @file.xml -u USER:PASS -H "Content-Type:application/xml" -v https://repository.apache.org/service/local/staging/profiles/d63f592e7eac0/start
83+
84+ # Using Nexus API documented here:
8485 # https://support.sonatype.com/entries/39720203-Uploading-to-a-Staging-Repository-via-REST-API
86+ echo " Creating Nexus staging repository"
87+ repo_request=" <promoteRequest><data><description>Apache Spark $GIT_TAG </description></data></promoteRequest>"
88+ out=$( curl -X POST -d " $repo_request " -u $ASF_USERNAME :$ASF_PASSWORD \
89+ -H " Content-Type:application/xml" -v \
90+ $NEXUS_ROOT /profiles/$NEXUS_PROFILE /start)
91+ staged_repo_id=$( echo $out | sed -e " s/.*\(orgapachespark-[0-9]\{4\}\).*/\1/" )
92+ echo " Created Nexus staging repository: $staged_repo_id "
8593
8694 rm -rf $SPARK_REPO
8795
@@ -110,17 +118,24 @@ if [[ ! "$@" =~ --package-only ]]; then
110118 gpg --print-md SHA1 $file > $file .sha1
111119 done
112120
113- echo " Uplading files to $NEXUS_REPOSITORY "
121+ echo " Uplading files to $NEXUS_UPLOAD "
114122 for file in $( find . -type f)
115123 do
116124 # strip leading ./
117125 file_short=$( echo $file | sed -e " s/\.\///" )
118- dest_url=" $NEXUS_REPOSITORY /org/apache/spark/$file_short "
126+ dest_url=" $NEXUS_UPLOAD /org/apache/spark/$file_short "
119127 echo " Uploading $file_short "
120128 curl -u $ASF_USERNAME :$ASF_PASSWORD --upload-file $file_short $dest_url
121129 done
122- popd
123130
131+ echo " Closing nexus staging repository"
132+ repo_request=" <promoteRequest><data><stagedRepositoryId>$staged_repo_id </stagedRepositoryId><description>Apache Spark $GIT_TAG </description></data></promoteRequest>"
133+ out=$( curl -X POST -d " $repo_request " -u $ASF_USERNAME :$ASF_PASSWORD \
134+ -H " Content-Type:application/xml" -v \
135+ $NEXUS_ROOT /profiles/$NEXUS_PROFILE /finish)
136+ echo " Closed Nexus staging repository: $staged_repo_id "
137+
138+ popd
124139 popd
125140 rm -rf spark
126141fi
0 commit comments