You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

7 years ago
7 years ago
  1. set -e
  2. exec 3>&1 # make stdout available as fd 3 for the result
  3. exec 1>&2 # redirect all output to stderr for logging
  4. # in_file_with_version() {
  5. # local artifacts_url=$1
  6. # local regex="(?<uri>$2)"
  7. # local version=$3
  8. #
  9. # result=$(artifactory_files "$artifacts_url" "$regex")
  10. # echo $result | jq --arg v "$version" '[foreach .[] as $item ([]; $item ; if $item.version == $v then $item else empty end)]'
  11. #
  12. # }
  13. #
  14. # retrieve current file version
  15. # e.g. curl -R -I $1
  16. check_version() {
  17. # retrieves HTTP header of file URL response
  18. local httpHeader=$(curl -R -I $1 2>&1 | grep 'Last-Modified:')
  19. # Checks if field "Last-Modified" exists in HTTP header and transform it into timestamp string
  20. # if that field is not present, return current timestamp
  21. if [ -z "$httpHeader" ]
  22. then
  23. # echo "Last-Modified information not returned for targeted file. Using current date's timestamp as version number."
  24. local dateString=$(date)
  25. else
  26. # echo "$httpHeader"
  27. local dateString=$(echo "$httpHeader" | sed -e "s/Last-Modified: //" | cut -d',' -f 2)
  28. fi
  29. date +"%Y%m%d%H%S" -d "$dateString"
  30. }