From 49937d2328b1233f544d8b4c0242e9b72be4b2a2 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 2 Mar 2017 11:57:20 +0100 Subject: [PATCH] TT#11544 wni: use workfront-jenkins-update to send notes * add branch info to messages * WORKFRONT_NOTE = True for prod Change-Id: Idb78932c262b3eb384d0f15c003e8c5c88761e57 --- repoapi/models/wni.py | 8 ++++---- repoapi/settings/prod.py | 2 +- repoapi/test/test_workfrontnote.py | 17 ++++++++++++----- repoapi/utils.py | 5 ++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/repoapi/models/wni.py b/repoapi/models/wni.py index 2bd7a68..ba63781 100644 --- a/repoapi/models/wni.py +++ b/repoapi/models/wni.py @@ -91,9 +91,9 @@ def workfront_note_manage(sender, **kwargs): if instance.jobname.endswith("-get-code") and \ instance.result == "SUCCESS": if instance.gerrit_eventtype == 'change-merged': - msg = "review merged" + msg = "[%s] review merged" elif instance.gerrit_eventtype == 'patchset-created': - msg = "review created" + msg = "[%s] review created" else: - msg = "commit created" - workfront_note_add(instance, msg) + msg = "[%s] commit created" + workfront_note_add(instance, msg % (instance.param_branch)) diff --git a/repoapi/settings/prod.py b/repoapi/settings/prod.py index b7bfb9d..df1a6ea 100644 --- a/repoapi/settings/prod.py +++ b/repoapi/settings/prod.py @@ -65,7 +65,7 @@ GERRIT_REST_HTTP_PASSWD = gerrit_config.get('gerrit', 'HTTP_PASSWD') GITWEB_URL = "https://git.mgm.sipwise.com/gitweb/?p={}.git;a=commit;h={}" WORKFRONT_CREDENTIALS = os.path.join(BASE_DIR, '/etc/jenkins_jobs/workfront.ini') -WORKFRONT_NOTE = False +WORKFRONT_NOTE = True # celery BROKER_URL = server_config.get('server', 'BROKER_URL') JBI_BASEDIR = os.path.join(VAR_DIR, 'jbi_files') diff --git a/repoapi/test/test_workfrontnote.py b/repoapi/test/test_workfrontnote.py index 8ded262..9c5385d 100644 --- a/repoapi/test/test_workfrontnote.py +++ b/repoapi/test/test_workfrontnote.py @@ -83,7 +83,9 @@ class WorkfrontNoteTestCase(BaseTest): workfront_id="0001", gerrit_change="2054") self.assertEquals(gri.count(), 1) - msg = "review created %s" % settings.GERRIT_URL.format("2054") + msg = "[%s] review created %s" % ( + param['param_branch'], + settings.GERRIT_URL.format("2054")) utils.assert_called_once_with("0001", msg) @patch('repoapi.utils.workfront_note_send') @@ -109,7 +111,9 @@ class WorkfrontNoteTestCase(BaseTest): workfront_id="0001", gerrit_change="7fg4567") self.assertEquals(gri.count(), 0) - msg = "review created %s" % settings.GERRIT_URL.format("2054") + msg = "[%s] review created %s" % ( + param['param_branch'], + settings.GERRIT_URL.format("2054")) utils.assert_called_once_with("0001", msg) param['jobname'] = "kamailio-get-code" @@ -126,7 +130,9 @@ class WorkfrontNoteTestCase(BaseTest): workfront_id="0001", gerrit_change="2054") self.assertEquals(gri.count(), 2) - msg = "review merged %s" % settings.GERRIT_URL.format("2054") + msg = "[%s] review merged %s" % ( + param['param_branch'], + settings.GERRIT_URL.format("2054")) utils.assert_called_with("0001", msg) @patch('repoapi.utils.workfront_note_send') @@ -148,6 +154,7 @@ class WorkfrontNoteTestCase(BaseTest): workfront_id="0001", gerrit_change="7fg4567") self.assertEquals(gri.count(), 1) - msg = "commit created %s" % settings.GITWEB_URL.format( - "kamailio", "7fg4567") + msg = "[%s] commit created %s" % ( + param['param_branch'], + settings.GITWEB_URL.format("kamailio", "7fg4567")) utils.assert_called_once_with("0001", msg) diff --git a/repoapi/utils.py b/repoapi/utils.py index c26cc9e..58e0948 100644 --- a/repoapi/utils.py +++ b/repoapi/utils.py @@ -126,13 +126,12 @@ def jenkins_get_artifact(jobname, buildnumber, artifact_info): def workfront_note_send(_id, message): command = [ - "/usr/bin/workfront-post-note", + "/usr/bin/workfront-jenkins-update", "--credfile=%s" % settings.WORKFRONT_CREDENTIALS, - "--private", "--taskid=%s" % _id, '--message="%s"' % message ] - logger.debug("workfront-port-note command: %s", command) + logger.debug("workfront-jenkins-update command: %s", command) res = executeAndReturnOutput(command) if res[0] != 0: logger.error("can't post workfront note. %s. %s", res[1], res[2])