Merge "Enable aggregate reports for controller"
[releng/builder.git] / jjb / autorelease / autorelease-maven-deploy.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2015 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11
12 STAGING_LOG="$WORKSPACE/deploy-staged-repository.log"
13
14 # Assuming that mvn deploy created the hide/from/pom/files/stage directory.
15 cd hide/from/pom/files || exit 1
16 mkdir -p m2repo/org/opendaylight/
17
18 # ODLNEXUSPROXY is used to define the location of the Nexus server used by the CI system.
19 # by default it should be set to https://nexus.opendaylight.org
20 # in cases where an internal ci system is using multiple NEXUS systems one for artifacts and another for staging,
21 # we can override using ODLNEXUS_STAGING_URL to route the staging build to the 2nd server.
22 # (most CI setups where a single Nexus server is used, ODLNEXUS_STAGING_URL should be left unset)
23 NEXUS_STAGING_URL=${ODLNEXUS_STAGING_URL:-"http://10.30.168.7:8081"}
24 NEXUS_STAGING_PROFILE=${ODLNEXUS_STAGING_PROFILE:-425e43800fea70}
25 NEXUS_STAGING_SERVER_ID=${ODLNEXUS_STAGING_SERVER_ID:-"opendaylight.staging"}
26
27 rsync -avz --remove-source-files \
28            --exclude 'maven-metadata*' \
29            --exclude '_remote.repositories' \
30            --exclude 'resolver-status.properties' \
31            "stage/org/opendaylight" m2repo/org/
32
33 "$MVN" -V -B org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy-staged-repository \
34     -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
35     -DrepositoryDirectory="$(pwd)/m2repo" \
36     -DnexusUrl="$NEXUS_STAGING_URL" \
37     -DstagingProfileId="$NEXUS_STAGING_PROFILE" \
38     -DserverId="$NEXUS_STAGING_SERVER_ID" \
39     -s "$SETTINGS_FILE" \
40     -gs "$GLOBAL_SETTINGS_FILE" | tee "$STAGING_LOG"
41
42 # Log all files larger than 200 MB into large-files.log
43 while IFS= read -r -d '' file
44 do
45     FILE_SIZE=$(du --summarize --block-size 1 "$file" | awk '{print $1}')
46     # Check if file size is larger than 200 MB
47     if [[ $FILE_SIZE -gt 209715200 ]]; then
48         echo "$FILE_SIZE $file" >> "$WORKSPACE/large-files.log"
49     fi
50 done <   <(find "$(pwd)/m2repo" -type f -print0)
51
52 # Detect if staging failed: mvn always exits 0 even if staging failed.
53 if grep '^\[ERROR\]' "$STAGING_LOG"; then
54     echo "Error creating staging repo. Refer to logs above for details."
55     exit 1
56 fi