Advertisement
Guest User

Untitled

a guest
Apr 10th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. set -e
  4.  
  5. function create_product () {
  6. eval $(minishift oc-env)
  7. oc login -u developer -p developer https://$(minishift ip):8443 \
  8. --insecure-skip-tls-verify=true
  9. oc project cpaas-dev
  10. jenkins_url=$(oc get route/jenkins0 -o=json | jq .spec.host | tr -d \")
  11. sa_secret_name=$(oc describe serviceaccount jenkins | grep Tokens | awk '{print $2}')
  12. jenkins_token=$(oc describe secret $sa_secret_name | grep token: | awk '{print $2}')
  13. sessionid=$(curl -X GET https://${jenkins_url}/job/Product-Pipeline/build \
  14. -H "Authorization: Bearer ${jenkins_token}" \
  15. -H "Jenkins-Crumb: 238e4690e619ee1260e49f416c0ec88b" \
  16. -H "cache-control: no-cache" -i --insecure --silent | grep JSESSIONID | \
  17. awk '{print $2}' | cut -d';' -f1)
  18.  
  19. crumb=$(curl -X GET -H "Authorization: Bearer ${jenkins_token}" \
  20. https://${jenkins_url}/crumbIssuer/api/json -k \
  21. -H 'Jenkins-Crumb: 238e4690e619ee1260e49f416c0ec88b' \
  22. -H 'cache-control: no-cache' --insecure --silent | jq .crumb | tr -d \")
  23.  
  24. curl -X POST --cookie "${sessionid}" \
  25. https://${jenkins_url}/job/Product-Pipeline/build \
  26. -H "Jenkins-Crumb: ${crumb}" \
  27. -H "cache-control: no-cache" \
  28. --data-urlencode json='{"parameter": [{"name": "productName", "value": "CNV"}, {"name": "productid", "value": "10"}, {"name": "productRepo", "value": "https://gitlab.sat.engineering.redhat.com/cpaas/product.git"}, {"name": "productBranch", "value": "development"}]}' \
  29. --insecure --silent
  30. }
  31.  
  32. function product_jenkins_console () {
  33. eval $(minishift oc-env)
  34. oc login -u developer -p developer https://$(minishift ip):8443 \
  35. --insecure-skip-tls-verify=true
  36. oc project cnv
  37. jenkins_url=$(oc get route/jenkins -o=json | jq .spec.host | tr -d \")
  38. chrome --ignore-certificate-errors https://${jenkins_url}
  39. }
  40.  
  41. if [[ ! -x "$(command -v ansible)" || \
  42. ! -x "$(command -v git)" || \
  43. ! -x "$(command -v tar)" ||\
  44. ! -x "$(command -v unzip)" || \
  45. ! -x "$(command -v wget)" ||
  46. ! -x "$(command -v jq)" ]]; then
  47. sudo yum install ansible git tar unzip wget jq
  48. fi
  49.  
  50. minishift stop
  51. minishift delete
  52. rm -rf ~/.minishift
  53.  
  54. (
  55. cd ../../gitlab.sat.engineering.redhat.com/lmilbaum/
  56. ls service/config/password.txt
  57. ansible-playbook -vv -i "localhost," contra-env-setup/playbooks/setup.yml \
  58. --vault-password-file=service/config/password.txt \
  59. --connection=local -K \
  60. -e vault_password="$(cat service/config/password.txt)" \
  61. -e @service/config/cpaas-env-setup.yml \
  62. -e @service/config/ansible/cpaas-vault.yml \
  63. -e user=$USER \
  64. --extra-vars='{"hooks": ["{{ project_dir }}/config/post_deployment_tasks.yml"]}'
  65. )
  66.  
  67. create_product
  68. product_jenkins_console
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement