From: hyokeun Date: Tue, 22 Aug 2017 12:05:25 +0000 (+0900) Subject: TPE-208 Test trigger - remove hard-coded branch X-Git-Tag: submit/trunk/20190927.012743~316^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F145492%2F1;p=services%2Fjenkins-scripts.git TPE-208 Test trigger - remove hard-coded branch Change-Id: I73d299bb8eaadf11f2cda67cd304add69391617c --- diff --git a/job_test_trigger_automation.py b/job_test_trigger_automation.py index 39daee7..27f0a58 100644 --- a/job_test_trigger_automation.py +++ b/job_test_trigger_automation.py @@ -22,7 +22,7 @@ import os import sys import base64 import json - +import ast from common.gerrit import get_gerrit_event, GerritEnv from common.git import Git, clone_gitproject @@ -129,20 +129,17 @@ def public_trigger_for_tester(events, gerrit_env): # set the jenkins info refname = os.getenv("GERRIT_REFNAME") print 'refname : %s\n' % refname - if refname == 'tizen_3.0': - url_lst = os.getenv("TEST_JENKINS_URL").split(',') - user_lst = os.getenv("TEST_JENKINS_USER").split(',') - token_lst = os.getenv("TEST_JENKINS_PW").split(',') - name_lst = os.getenv("TEST_JOB_NAME").split(',') - elif refname == 'tizen': - url_lst = os.getenv("PUBLIC_TEST_JENKINS_URL").split(',') - user_lst = os.getenv("PUBLIC_TEST_JENKINS_USER").split(',') - token_lst = os.getenv("PUBLIC_TEST_JENKINS_API_TOKEN").split(',') - name_lst = os.getenv("PUBLIC_TEST_JENKINS_JOB_NAME").split(',') - else: + + public_test_mapping = ast.literal_eval(os.getenv('PUBLIC_TEST_MAPPING')) + if refname not in public_test_mapping: print 'In case of %s branch, do nothing!!\n' % refname return + url_lst = public_test_mapping[refname].get('urls') + user_lst = public_test_mapping[refname].get('users') + token_lst = public_test_mapping[refname].get('tokens') + name_lst = public_test_mapping[refname].get('jobs') + # remote trigger by using file param files_dict = {} for each_url, each_user, each_token, each_name in \ @@ -156,6 +153,7 @@ def public_trigger_for_tester(events, gerrit_env): files_dict[each_name] = [(fname, fname)] + print 'Requesting... %s, %s' % (each_url, each_name) remote_jenkins_build_job(each_url, each_user, each_token, each_name, None, None, files_dict[each_name]) @@ -171,11 +169,7 @@ def main(): # check the envs if not os.getenv("PUBLIC_GIT_CACHE_DIR") or \ not os.getenv("GERRIT_NEWREV") or \ - not os.getenv("PUBLIC_TEST_AUTOMATION_ENABLED") or \ - not os.getenv("PUBLIC_TEST_JENKINS_URL") or \ - not os.getenv("PUBLIC_TEST_JENKINS_USER") or \ - not os.getenv("PUBLIC_TEST_JENKINS_API_TOKEN") or \ - not os.getenv("PUBLIC_TEST_JENKINS_JOB_NAME"): + not os.getenv("PUBLIC_TEST_MAPPING"): print 'need to check envs!!\n' return @@ -191,3 +185,4 @@ def main(): if __name__ == "__main__": sys.exit(main()) +