Add jenkins protocol with default value
Change-Id: Iabb4181075b626d74b11c9252147746c3cfd699a
diff --git a/tcp_tests/managers/jenkins/client.py b/tcp_tests/managers/jenkins/client.py
index 39c698e..a7c2315 100644
--- a/tcp_tests/managers/jenkins/client.py
+++ b/tcp_tests/managers/jenkins/client.py
@@ -11,41 +11,15 @@
from requests.exceptions import ConnectionError
-class JenkinsWrapper(jenkins.Jenkins):
- """Workaround for the bug:
- https://bugs.launchpad.net/python-jenkins/+bug/1775047
- """
- def _response_handler(self, response):
- '''Handle response objects'''
-
- # raise exceptions if occurred
- response.raise_for_status()
-
- headers = response.headers
- if (headers.get('content-length') is None and
- headers.get('transfer-encoding') is None and
- (response.status_code == 201 and
- headers.get('location') is None) and
- (response.content is None or len(response.content) <= 0)):
- # response body should only exist if one of these is provided
- raise jenkins.EmptyResponseException(
- "Error communicating with server[%s]: "
- "empty response" % self.server)
-
- # Response objects will automatically return unicode encoded
- # when accessing .text property
- return response
-
-
class JenkinsClient(object):
def __init__(self, host=None, username='admin', password='r00tme'):
host = host or 'http://172.16.44.33:8081'
- # self.__client = jenkins.Jenkins(
- self.__client = JenkinsWrapper(
+ self.__client = jenkins.Jenkins(
host,
username=username,
password=password)
+ self.__client._session.verify = False
def jobs(self):
return self.__client.get_jobs()
diff --git a/tcp_tests/managers/saltmanager.py b/tcp_tests/managers/saltmanager.py
index 5fabdd8..226f408 100644
--- a/tcp_tests/managers/saltmanager.py
+++ b/tcp_tests/managers/saltmanager.py
@@ -336,13 +336,25 @@
tgt = 'I@docker:client:stack:jenkins and cfg01*'
jenkins_params = self.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master")
- jenkins_port = jenkins_params['port']
- jenkins_user = jenkins_params['username']
- jenkins_pass = jenkins_params['password']
+ jenkins_host = jenkins_params.get('host')
+ jenkins_port = jenkins_params.get('port')
+ jenkins_protocol = jenkins_params.get('proto', 'http')
+ jenkins_user = jenkins_params.get('username', 'admin')
+ jenkins_pass = jenkins_params.get('password')
+
+ if not all([jenkins_host,
+ jenkins_port,
+ jenkins_protocol,
+ jenkins_user,
+ jenkins_pass]):
+ raise LookupError(
+ "Some of the required parameters for Jenkins not set in the "
+ "pillar jenkins:client:master on {0}: {1}"
+ .format(tgt, jenkins_params))
with open(env_jenkins_day01_filename, 'w') as f:
f.write(
- 'export JENKINS_URL=http://{host}:{port}\n'
+ 'export JENKINS_URL={protocol}://{host}:{port}\n'
'export JENKINS_USER={user}\n'
'export JENKINS_PASS={password}\n'
'export JENKINS_START_TIMEOUT=60\n'
@@ -357,8 +369,9 @@
' # Timeout waiting for job in queue to start building"\n'
'echo "export JENKINS_BUILD_TIMEOUT=${{JENKINS_BUILD_TIMEOUT}}'
' # Timeout waiting for building job to complete"\n'
- .format(host=self.host, port=jenkins_port,
- user=jenkins_user, password=jenkins_pass)
+ .format(host=jenkins_host, port=jenkins_port,
+ protocol=jenkins_protocol, user=jenkins_user,
+ password=jenkins_pass)
)
def create_env_jenkins_cicd(self):
@@ -377,14 +390,25 @@
.format(env_jenkins_cicd_filename, tgt, e.message))
return
- jenkins_host = jenkins_params['host']
- jenkins_port = jenkins_params['port']
- jenkins_user = jenkins_params['username']
- jenkins_pass = jenkins_params['password']
+ jenkins_host = jenkins_params.get('host')
+ jenkins_port = jenkins_params.get('port')
+ jenkins_protocol = jenkins_params.get('proto', 'http')
+ jenkins_user = jenkins_params.get('username', 'admin')
+ jenkins_pass = jenkins_params.get('password')
+
+ if not all([jenkins_host,
+ jenkins_port,
+ jenkins_protocol,
+ jenkins_user,
+ jenkins_pass]):
+ raise LookupError(
+ "Some of the required parameters for Jenkins not set in the "
+ "pillar jenkins:client:master on {0}: {1}"
+ .format(tgt, jenkins_params))
with open(env_jenkins_cicd_filename, 'w') as f:
f.write(
- 'export JENKINS_URL=http://{host}:{port}\n'
+ 'export JENKINS_URL={protocol}://{host}:{port}\n'
'export JENKINS_USER={user}\n'
'export JENKINS_PASS={password}\n'
'export JENKINS_START_TIMEOUT=60\n'
@@ -400,7 +424,8 @@
'echo "export JENKINS_BUILD_TIMEOUT=${{JENKINS_BUILD_TIMEOUT}}'
' # Timeout waiting for building job to complete"\n'
.format(host=jenkins_host, port=jenkins_port,
- user=jenkins_user, password=jenkins_pass)
+ protocol=jenkins_protocol, user=jenkins_user,
+ password=jenkins_pass)
)
def create_env_k8s(self):
diff --git a/tcp_tests/tests/system/test_cvp_pipelines.py b/tcp_tests/tests/system/test_cvp_pipelines.py
index a21d2c2..c73bb88 100644
--- a/tcp_tests/tests/system/test_cvp_pipelines.py
+++ b/tcp_tests/tests/system/test_cvp_pipelines.py
@@ -53,7 +53,11 @@
tgt=tgt, pillar="jenkins:client:master:host")
jenkins_port = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:port")
- jenkins_url = 'http://{0}:{1}'.format(jenkins_host, jenkins_port)
+ jenkins_protocol = salt.get_single_pillar(
+ tgt=tgt, pillar="jenkins:client:master:proto")
+ jenkins_url = '{0}://{1}:{2}'.format(jenkins_protocol,
+ jenkins_host,
+ jenkins_port)
jenkins_user = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:username")
jenkins_pass = salt.get_single_pillar(
@@ -113,7 +117,11 @@
tgt=tgt, pillar="jenkins:client:master:host")
jenkins_port = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:port")
- jenkins_url = 'http://{0}:{1}'.format(jenkins_host, jenkins_port)
+ jenkins_protocol = salt.get_single_pillar(
+ tgt=tgt, pillar="jenkins:client:master:proto")
+ jenkins_url = '{0}://{1}:{2}'.format(jenkins_protocol,
+ jenkins_host,
+ jenkins_port)
jenkins_user = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:username")
jenkins_pass = salt.get_single_pillar(
@@ -209,7 +217,11 @@
tgt=tgt, pillar="jenkins:client:master:host")
jenkins_port = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:port")
- jenkins_url = 'http://{0}:{1}'.format(jenkins_host, jenkins_port)
+ jenkins_protocol = salt.get_single_pillar(
+ tgt=tgt, pillar="jenkins:client:master:proto")
+ jenkins_url = '{0}://{1}:{2}'.format(jenkins_protocol,
+ jenkins_host,
+ jenkins_port)
jenkins_user = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:username")
jenkins_pass = salt.get_single_pillar(
@@ -273,7 +285,11 @@
tgt=tgt, pillar="jenkins:client:master:host")
jenkins_port = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:port")
- jenkins_url = 'http://{0}:{1}'.format(jenkins_host, jenkins_port)
+ jenkins_protocol = salt.get_single_pillar(
+ tgt=tgt, pillar="jenkins:client:master:proto")
+ jenkins_url = '{0}://{1}:{2}'.format(jenkins_protocol,
+ jenkins_host,
+ jenkins_port)
jenkins_user = salt.get_single_pillar(
tgt=tgt, pillar="jenkins:client:master:username")
jenkins_pass = salt.get_single_pillar(