Update SPDX License header to 2.0 format
[releng/builder.git] / jjb / autorelease / include-raw-autorelease-maven-deploy.sh
index 23e606bb76ced63ee15dbab397ee151b718a9375..8d24150c9a1da5f08e30180b130e652efc47a14e 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+# SPDX-License-Identifier: EPL-1.0
 ##############################################################################
 # Copyright (c) 2015 The Linux Foundation and others.
 #
@@ -9,30 +9,48 @@
 # http://www.eclipse.org/legal/epl-v10.html
 ##############################################################################
 
+STAGING_LOG="$WORKSPACE/deploy-staged-repository.log"
+
 # Assuming that mvn deploy created the hide/from/pom/files/stage directory.
-cd hide/from/pom/files
+cd hide/from/pom/files || exit 1
 mkdir -p m2repo/org/opendaylight/
 
-(IFS='
-'
-for m in `xmlstarlet sel -N x=http://maven.apache.org/POM/4.0.0 -t -m '//x:modules' -v '//x:module' ../../../../pom.xml`; do
-    rsync -avz --exclude 'maven-metadata*' \
-               --exclude '_remote.repositories' \
-               --exclude 'resolver-status.properties' \
-               "stage/org/opendaylight/$m" m2repo/org/opendaylight/
-done)
+# ODLNEXUSPROXY is used to define the location of the Nexus server used by the CI system.
+# by default it should be set to https://nexus.opendaylight.org
+# in cases where an internal ci system is using multiple NEXUS systems one for artifacts and another for staging,
+# we can override using ODLNEXUS_STAGING_URL to route the staging build to the 2nd server.
+# (most CI setups where a single Nexus server is used, ODLNEXUS_STAGING_URL should be left unset)
+NEXUS_STAGING_URL=${ODLNEXUS_STAGING_URL:-"http://10.29.8.46:8081"}
+NEXUS_STAGING_PROFILE=${ODLNEXUS_STAGING_PROFILE:-425e43800fea70}
+NEXUS_STAGING_SERVER_ID=${ODLNEXUS_STAGING_SERVER_ID:-"opendaylight.staging"}
 
-# Add exception for integration project since they release under the
-# integration top-level project.
-rsync -avz --exclude 'maven-metadata*' \
+rsync -avz --remove-source-files \
+           --exclude 'maven-metadata*' \
            --exclude '_remote.repositories' \
            --exclude 'resolver-status.properties' \
-           "stage/org/opendaylight/integration" m2repo/org/opendaylight/
+           "stage/org/opendaylight" m2repo/org/
+
+"$MVN" -V -B org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy-staged-repository \
+    -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
+    -DrepositoryDirectory="$(pwd)/m2repo" \
+    -DnexusUrl="$NEXUS_STAGING_URL" \
+    -DstagingProfileId="$NEXUS_STAGING_PROFILE" \
+    -DserverId="$NEXUS_STAGING_SERVER_ID" \
+    -s "$SETTINGS_FILE" \
+    -gs "$GLOBAL_SETTINGS_FILE" | tee "$STAGING_LOG"
+
+# Log all files larger than 200 MB into large-files.log
+while IFS= read -r -d '' file
+do
+    FILE_SIZE=$(du --summarize --block-size 1 "$file" | awk '{print $1}')
+    # Check if file size is larger than 200 MB
+    if [[ $FILE_SIZE -gt 209715200 ]]; then
+        echo "$FILE_SIZE $file" >> "$WORKSPACE/large-files.log"
+    fi
+done <   <(find "$(pwd)/m2repo" -type f -print0)
 
-mvn -V -B org.sonatype.plugins:nexus-staging-maven-plugin:1.6.2:deploy-staged-repository \
-    -DrepositoryDirectory="`pwd`/m2repo" \
-    -DnexusUrl=https://nexus.opendaylight.org/ \
-    -DstagingProfileId="425e43800fea70" \
-    -DserverId="opendaylight.staging" \
-    -s $SETTINGS_FILE \
-    -gs $GLOBAL_SETTINGS_FILE | tee $WORKSPACE/deploy-staged-repository.log
+# Detect if staging failed: mvn always exits 0 even if staging failed.
+if grep '^\[ERROR\]' "$STAGING_LOG"; then
+    echo "Error creating staging repo. Refer to logs above for details."
+    exit 1
+fi