From: Thanh Ha Date: Wed, 21 Jun 2017 18:36:29 +0000 (-0400) Subject: Re-organize functions alphabetically X-Git-Tag: v0.5.0~5 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F71%2F5271%2F1;p=releng%2Flftools.git Re-organize functions alphabetically Missed this when we merged the maven-file code. L comes before M. Change-Id: I46e0bbc622599ddf2ed2fa25e7dde4c9bb3bf54b Signed-off-by: Thanh Ha --- diff --git a/shell/deploy b/shell/deploy index 67316cd5..d8e28c97 100755 --- a/shell/deploy +++ b/shell/deploy @@ -167,6 +167,85 @@ deploy_archives() { rm -rf "$tmpdir" } +deploy_logs() { + # Deploy logs to a Nexus site repository named logs. + # + # This script fetches logs and system information and pushes them to Nexus + # for log archiving. + # + # To use this script the Nexus server must have a site repository configured + # with the name "logs" as this is a hardcoded path. Also this script uses + # ~/.netrc for it's authentication which must be provided. + # + # Usage: deploy + # + # : URL of Nexus server. Eg: https://nexus.opendaylight.org + # : Path on nexus logs repo to place the logs. Eg: + # $SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER + # : URL of the Jenkins build. Jenkins typicallyi provides this + # via the $BUILD_URL environment variable. + + if [ -z "$3" ]; then + echo "Missing required arguments." + echo "Usage: deploy " + exit 1 + fi + + local nexus_url="$1" + local nexus_path="$2" + local build_url="$3" + + tmpdir=$(mktemp -d) + pushd "$tmpdir" + + touch "_build-details.log" + { + echo "build-url: ${build_url}" + } 2>&1 | tee -a "_build-details.log" + env | grep -v PASSWORD | sort > "_build-enviroment-variables.log" + + # Print system info before collecting logs + touch "_sys-info.log" + { + local sys_cmds + sys_cmds=( + "uname -a" + "lscpu" + "nproc" + "df -h" + "free -m" + "ip addr" + "sar -r" + ) + for cmd in "${sys_cmds[@]}"; do + # If command exists then print output. + set -- $cmd + hash $1 2> /dev/null + if [ "$?" -eq "0" ]; then + echo -e "---> $cmd:\n $($cmd) \n" + fi + done + } 2>&1 | tee -a "_sys-info.log" + + # Magic string used to trim console logs at the appropriate level during wget + MAGIC_STRING="-----END_OF_BUILD-----" + echo "$MAGIC_STRING" + + wget --no-verbose -O "console.log" "${build_url}consoleText" + wget --no-verbose -O "console-timestamp.log" "${build_url}/timestamps?time=HH:mm:ss&appendLog" + sed -i "/^$MAGIC_STRING$/q" "console.log" + sed -i "/^.*$MAGIC_STRING$/q" "console-timestamp.log" + + gzip -- *.log + zip -r console-logs.zip -- *.log.gz + + curl --netrc --upload-file console-logs.zip \ + "${nexus_url}/service/local/repositories/logs/content-compressed/${nexus_path}" + + popd + rm -rf "$tmpdir" +} + deploy_maven_file_usage () { echo "Usage: $0 " echo "" @@ -394,85 +473,6 @@ deploy_maven_file () { fi } -deploy_logs() { - # Deploy logs to a Nexus site repository named logs. - # - # This script fetches logs and system information and pushes them to Nexus - # for log archiving. - # - # To use this script the Nexus server must have a site repository configured - # with the name "logs" as this is a hardcoded path. Also this script uses - # ~/.netrc for it's authentication which must be provided. - # - # Usage: deploy - # - # : URL of Nexus server. Eg: https://nexus.opendaylight.org - # : Path on nexus logs repo to place the logs. Eg: - # $SILO/$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER - # : URL of the Jenkins build. Jenkins typicallyi provides this - # via the $BUILD_URL environment variable. - - if [ -z "$3" ]; then - echo "Missing required arguments." - echo "Usage: deploy " - exit 1 - fi - - local nexus_url="$1" - local nexus_path="$2" - local build_url="$3" - - tmpdir=$(mktemp -d) - pushd "$tmpdir" - - touch "_build-details.log" - { - echo "build-url: ${build_url}" - } 2>&1 | tee -a "_build-details.log" - env | grep -v PASSWORD | sort > "_build-enviroment-variables.log" - - # Print system info before collecting logs - touch "_sys-info.log" - { - local sys_cmds - sys_cmds=( - "uname -a" - "lscpu" - "nproc" - "df -h" - "free -m" - "ip addr" - "sar -r" - ) - for cmd in "${sys_cmds[@]}"; do - # If command exists then print output. - set -- $cmd - hash $1 2> /dev/null - if [ "$?" -eq "0" ]; then - echo -e "---> $cmd:\n $($cmd) \n" - fi - done - } 2>&1 | tee -a "_sys-info.log" - - # Magic string used to trim console logs at the appropriate level during wget - MAGIC_STRING="-----END_OF_BUILD-----" - echo "$MAGIC_STRING" - - wget --no-verbose -O "console.log" "${build_url}consoleText" - wget --no-verbose -O "console-timestamp.log" "${build_url}/timestamps?time=HH:mm:ss&appendLog" - sed -i "/^$MAGIC_STRING$/q" "console.log" - sed -i "/^.*$MAGIC_STRING$/q" "console-timestamp.log" - - gzip -- *.log - zip -r console-logs.zip -- *.log.gz - - curl --netrc --upload-file console-logs.zip \ - "${nexus_url}/service/local/repositories/logs/content-compressed/${nexus_path}" - - popd - rm -rf "$tmpdir" -} - deploy_nexus() { # Deploy Maven artifacts to Nexus using curl #