Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -e
- function create_product () {
- eval $(minishift oc-env)
- oc login -u developer -p developer https://$(minishift ip):8443 \
- --insecure-skip-tls-verify=true
- oc project cpaas-dev
- jenkins_url=$(oc get route/jenkins0 -o=json | jq .spec.host | tr -d \")
- sa_secret_name=$(oc describe serviceaccount jenkins | grep Tokens | awk '{print $2}')
- jenkins_token=$(oc describe secret $sa_secret_name | grep token: | awk '{print $2}')
- sessionid=$(curl -X GET https://${jenkins_url}/job/Product-Pipeline/build \
- -H "Authorization: Bearer ${jenkins_token}" \
- -H "Jenkins-Crumb: 238e4690e619ee1260e49f416c0ec88b" \
- -H "cache-control: no-cache" -i --insecure --silent | grep JSESSIONID | \
- awk '{print $2}' | cut -d';' -f1)
- crumb=$(curl -X GET -H "Authorization: Bearer ${jenkins_token}" \
- https://${jenkins_url}/crumbIssuer/api/json -k \
- -H 'Jenkins-Crumb: 238e4690e619ee1260e49f416c0ec88b' \
- -H 'cache-control: no-cache' --insecure --silent | jq .crumb | tr -d \")
- curl -X POST --cookie "${sessionid}" \
- https://${jenkins_url}/job/Product-Pipeline/build \
- -H "Jenkins-Crumb: ${crumb}" \
- -H "cache-control: no-cache" \
- --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"}]}' \
- --insecure --silent
- }
- function product_jenkins_console () {
- eval $(minishift oc-env)
- oc login -u developer -p developer https://$(minishift ip):8443 \
- --insecure-skip-tls-verify=true
- oc project cnv
- jenkins_url=$(oc get route/jenkins -o=json | jq .spec.host | tr -d \")
- chrome --ignore-certificate-errors https://${jenkins_url}
- }
- if [[ ! -x "$(command -v ansible)" || \
- ! -x "$(command -v git)" || \
- ! -x "$(command -v tar)" ||\
- ! -x "$(command -v unzip)" || \
- ! -x "$(command -v wget)" ||
- ! -x "$(command -v jq)" ]]; then
- sudo yum install ansible git tar unzip wget jq
- fi
- minishift stop
- minishift delete
- rm -rf ~/.minishift
- (
- cd ../../gitlab.sat.engineering.redhat.com/lmilbaum/
- ls service/config/password.txt
- ansible-playbook -vv -i "localhost," contra-env-setup/playbooks/setup.yml \
- --vault-password-file=service/config/password.txt \
- --connection=local -K \
- -e vault_password="$(cat service/config/password.txt)" \
- -e @service/config/cpaas-env-setup.yml \
- -e @service/config/ansible/cpaas-vault.yml \
- -e user=$USER \
- --extra-vars='{"hooks": ["{{ project_dir }}/config/post_deployment_tasks.yml"]}'
- )
- create_product
- product_jenkins_console
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement