blob: 72a85475e376852240154e5788d443775042124d [file] [log] [blame]
Dennis Dmitriev3ec2e532018-06-08 04:33:34 +03001#!/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
14CURRENT_DIR=$(dirname $(readlink -f "${BASH_SOURCE[0]}"))
15export PYTHONPATH="${CURRENT_DIR}/../.."
16
17if [ -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
24else
Tatyana Leontovichbbdc3db2018-12-06 09:27:26 +020025 MASTER_TARGET='I@docker:client:stack:jenkins and cid01*'
26 export JENKINS_HOST=$(${CURRENT_DIR}/get_param.py -C "${MASTER_TARGET}" pillar.get jenkins:client:master:host)
27 export JENKINS_PORT=$(${CURRENT_DIR}/get_param.py -C "${MASTER_TARGET}" pillar.get jenkins:client:master:port)
Dennis Dmitriev3ec2e532018-06-08 04:33:34 +030028 export JENKINS_URL=http://${JENKINS_HOST}:${JENKINS_PORT}
Tatyana Leontovichbbdc3db2018-12-06 09:27:26 +020029 export JENKINS_USER=$(${CURRENT_DIR}/get_param.py -C "${MASTER_TARGET}" pillar.get jenkins:client:master:username)
30 export JENKINS_PASS=$(${CURRENT_DIR}/get_param.py -C "${MASTER_TARGET}" pillar.get jenkins:client:master:password)
Dennis Dmitriev3ec2e532018-06-08 04:33:34 +030031 export JENKINS_START_TIMEOUT=60
32 export JENKINS_BUILD_TIMEOUT=1800
33fi
34
35echo "export JENKINS_URL='$JENKINS_URL' # Jenkins API URL"
36echo "export JENKINS_USER='${JENKINS_USER}' # Jenkins API username"
37echo "export JENKINS_PASS='${JENKINS_PASS}' # Jenkins API password or token"
38echo "export JENKINS_START_TIMEOUT='${JENKINS_START_TIMEOUT}' # Timeout waiting for job in queue to start building"
39echo "export JENKINS_BUILD_TIMEOUT='${JENKINS_BUILD_TIMEOUT}' # Timeout waiting for building job to complete"