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.

100 lines
3.1 KiB

8 years ago
  1. #!/bin/bash
  2. set -e
  3. source $(dirname $0)/helpers.sh
  4. # Export these vars, or let the script prompt you for them
  5. #export MAVEN_RELEASES_URL=http://myrepo.com/repository/releases/
  6. #export MAVEN_SNAPSHOTS_URL=http://myrepo.com/repository/snapshots/
  7. #export MAVEN_REPO_USERNAME=username
  8. #export MAVEN_REPO_PASSWORD=password
  9. #export MAVEN_REPOSITORY_CERT=$(cat /path/to/cert)
  10. if [ -z "$MAVEN_RELEASES_URL" ]; then
  11. echo "Maven Releases Repo URL: "
  12. read -r MAVEN_RELEASES_URL
  13. fi
  14. if [ -z "$MAVEN_SNAPSHOTS_URL" ]; then
  15. echo "Maven Snapshots Repo URL: "
  16. read -r MAVEN_SNAPSHOTS_URL
  17. fi
  18. if [ -z "$MAVEN_REPO_USERNAME" ]; then
  19. echo "Maven Repo Username: "
  20. read -r MAVEN_REPO_USERNAME
  21. fi
  22. if [ -z "$MAVEN_REPO_PASSWORD" ]; then
  23. echo "Maven Repo Password: "
  24. read -r MAVEN_REPO_PASSWORD
  25. fi
  26. it_can_deploy_release_to_manager_without_pom() {
  27. local src=$(mktemp -d $TMPDIR/out-src.XXXXXX)
  28. local url=$MAVEN_RELEASES_URL
  29. local version=1.0.0-rc.0
  30. local username=$MAVEN_REPO_USERNAME
  31. local password=$MAVEN_REPO_PASSWORD
  32. local repository_cert=$MAVEN_REPOSITORY_CERT
  33. deploy_without_pom_with_credentials $url $version $username $password "$repository_cert" $src | jq -e "
  34. .version == {version: $(echo $version | jq -R .)}
  35. "
  36. }
  37. it_can_deploy_snapshot_to_manager_without_pom() {
  38. local src=$(mktemp -d $TMPDIR/out-src.XXXXXX)
  39. local url=$MAVEN_SNAPSHOTS_URL
  40. local version=1.0.0-rc.0-SNAPSHOT
  41. local username=$MAVEN_REPO_USERNAME
  42. local password=$MAVEN_REPO_PASSWORD
  43. local repository_cert=$MAVEN_REPOSITORY_CERT
  44. deploy_without_pom_with_credentials $url $version $username $password "$repository_cert" $src | jq -e "
  45. .version == {version: $(echo $version | jq -R .)}
  46. "
  47. }
  48. it_can_deploy_release_to_manager_with_pom() {
  49. local src=$(mktemp -d $TMPDIR/out-src.XXXXXX)
  50. mkdir $src/project
  51. cp $(dirname $0)/resources/pom-release.xml $src/project/pom.xml
  52. local url=$MAVEN_RELEASES_URL
  53. local pom=$src/project/pom.xml
  54. local version=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" $pom)
  55. local username=$MAVEN_REPO_USERNAME
  56. local password=$MAVEN_REPO_PASSWORD
  57. local repository_cert=$MAVEN_REPOSITORY_CERT
  58. deploy_with_pom_with_credentials $url $pom $username $password "$repository_cert" $src | jq -e "
  59. .version == {version: $(echo $version | jq -R .)}
  60. "
  61. }
  62. it_can_deploy_snapshot_to_manager_with_pom() {
  63. local src=$(mktemp -d $TMPDIR/out-src.XXXXXX)
  64. mkdir $src/project
  65. cp $(dirname $0)/resources/pom-snapshot.xml $src/project/pom.xml
  66. local url=$MAVEN_SNAPSHOTS_URL
  67. local pom=$src/project/pom.xml
  68. local version=$(xmllint --xpath "//*[local-name()='project']/*[local-name()='version']/text()" $pom)
  69. local username=$MAVEN_REPO_USERNAME
  70. local password=$MAVEN_REPO_PASSWORD
  71. local repository_cert=$MAVEN_REPOSITORY_CERT
  72. deploy_with_pom_with_credentials $url $pom $username $password "$repository_cert" $src | jq -e "
  73. .version == {version: $(echo $version | jq -R .)}
  74. "
  75. }
  76. run it_can_deploy_release_to_manager_without_pom
  77. run it_can_deploy_snapshot_to_manager_without_pom
  78. run it_can_deploy_release_to_manager_with_pom
  79. run it_can_deploy_snapshot_to_manager_with_pom