promote.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. set -e
  3. source $(dirname $0)/common.sh
  4. buildName=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.name' )
  5. buildNumber=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.number' )
  6. version=$( cat artifactory-repo/build-info.json | jq -r '.buildInfo.modules[0].id' | sed 's/.*:.*:\(.*\)/\1/' )
  7. if [[ $RELEASE_TYPE = "M" ]]; then
  8. targetRepo="libs-milestone-local"
  9. elif [[ $RELEASE_TYPE = "RC" ]]; then
  10. targetRepo="libs-milestone-local"
  11. elif [[ $RELEASE_TYPE = "RELEASE" ]]; then
  12. targetRepo="libs-release-local"
  13. else
  14. echo "Unknown release type $RELEASE_TYPE" >&2; exit 1;
  15. fi
  16. echo "Promoting ${buildName}/${buildNumber} to ${targetRepo}"
  17. curl \
  18. -s \
  19. --connect-timeout 240 \
  20. --max-time 900 \
  21. -u ${ARTIFACTORY_USERNAME}:${ARTIFACTORY_PASSWORD} \
  22. -H "Content-type:application/json" \
  23. -d "{\"status\": \"staged\", \"sourceRepo\": \"libs-staging-local\", \"targetRepo\": \"${targetRepo}\"}" \
  24. -f \
  25. -X \
  26. POST "${ARTIFACTORY_SERVER}/api/build/promote/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to promote" >&2; exit 1; }
  27. echo "Promotion complete"
  28. echo $version > version/version