Dennis Dmitriev | 3ec2e53 | 2018-06-08 04:33:34 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Source file to set access credentials to Jenkins API on CICD cluster |
| 4 | # Requires parameters to work with libpepper: |
| 5 | # - SALTAPI_URL |
| 6 | # - SALTAPI_USER |
| 7 | # - SALTAPI_PASS |
| 8 | # Example usage: |
| 9 | # $> export ENV_NAME=some-test-environment |
| 10 | # $> . ./tcp_tests/utils/env_salt |
| 11 | # $> . ./tcp_tests/utils/env_jenkins_cicd |
| 12 | # $> ./tcp_tests/utils/run_jenkins_job.py --verbose --job-name=deploy_openstack --job-parameters="{... json ...}" |
| 13 | |
| 14 | CURRENT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}")) |
| 15 | export PYTHONPATH="${CURRENT_DIR}/../.." |
| 16 | |
| 17 | if [ -z "$SALTAPI_URL" ]; then |
| 18 | echo "$SALTAPI_URL not found in the environment variables, getting values from salt-master is impossible." |
| 19 | unset JENKINS_URL |
| 20 | unset JENKINS_USER |
| 21 | unset JENKINS_PASS |
| 22 | unset JENKINS_START_TIMEOUT |
| 23 | unset JENKINS_BUILD_TIMEOUT |
| 24 | else |
| 25 | MASTER="get_param.py -C I@docker:client:stack:jenkins pillar.get jenkins:client:master" |
| 26 | export JENKINS_HOST=$(${CURRENT_DIR}/${MASTER}:host) |
| 27 | export JENKINS_PORT=$(${CURRENT_DIR}/${MASTER}:port) |
| 28 | export JENKINS_URL=http://${JENKINS_HOST}:${JENKINS_PORT} |
| 29 | export JENKINS_USER=$(${CURRENT_DIR}/${MASTER}:username) |
| 30 | export JENKINS_PASS=$(${CURRENT_DIR}/${MASTER}:password) |
| 31 | export JENKINS_START_TIMEOUT=60 |
| 32 | export JENKINS_BUILD_TIMEOUT=1800 |
| 33 | fi |
| 34 | |
| 35 | echo "export JENKINS_URL='$JENKINS_URL' # Jenkins API URL" |
| 36 | echo "export JENKINS_USER='${JENKINS_USER}' # Jenkins API username" |
| 37 | echo "export JENKINS_PASS='${JENKINS_PASS}' # Jenkins API password or token" |
| 38 | echo "export JENKINS_START_TIMEOUT='${JENKINS_START_TIMEOUT}' # Timeout waiting for job in queue to start building" |
| 39 | echo "export JENKINS_BUILD_TIMEOUT='${JENKINS_BUILD_TIMEOUT}' # Timeout waiting for building job to complete" |