Add test trigger job for prerelease 55/123955/4
authorhyokeun <hyokeun.jeon@samsung.com>
Sat, 8 Apr 2017 23:32:35 +0000 (08:32 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Mon, 10 Apr 2017 04:55:17 +0000 (13:55 +0900)
Use case scenario:
1) This job is triggered when all images are created successfully.
   (post-image-creation)
2) This job updates a file 'prerelease.description' using the description of the corresponding OBS project.
3) The above update triggers 'gerrit-trigger' in TRBS jenkins.
4) TRBS jenkins job triggers test-trigger.

Change-Id: I1ae0cdfc22a7a6b5e442cc4bf9982091be111f66

debian/jenkins-scripts-common.install
job_post_image.py
job_test_trigger_info_update.py [new file with mode: 0644]
packaging/jenkins-scripts.spec

index 0530971..f183068 100644 (file)
@@ -17,6 +17,7 @@ debian/tmp/scripts/check_section.sh /var/lib/jenkins/jenkins-scripts/scripts/
 debian/tmp/scripts/get_git_desc_info.sh /var/lib/jenkins/jenkins-scripts/scripts/
 debian/tmp/job_buildmonitor.py /var/lib/jenkins/jenkins-scripts/
 debian/tmp/job_ref_snapshot_info_update.py /var/lib/jenkins/jenkins-scripts/
+debian/tmp/job_test_trigger_info_update.py /var/lib/jenkins/jenkins-scripts/
 debian/tmp/job_make_dep_graph.py /var/lib/jenkins/jenkins-scripts/
 debian/tmp/common/dep_graph.php.template /var/lib/jenkins/jenkins-scripts/common/
 debian/tmp/common/dep_graph.php.template_simple /var/lib/jenkins/jenkins-scripts/common/
index ab1b593..d162104 100755 (executable)
@@ -107,6 +107,8 @@ def main():
             if after_update_img_cnt == target_img_cnt:
                 print '[%s] reached the target_img_cnt(%s)!! trigger BUILD-MONITOR(Post_Image)\n' \
                       % (__file__, target_img_cnt)
+                trigger_next("TEST-TRIGGER-INFO-UPDATE", saveinfo)
+
                 if buildmonitor_enabled:
                     #buildmonitor.end_create_image_for_sr_stage(bm_start_datetime,
                     #                                           project)
diff --git a/job_test_trigger_info_update.py b/job_test_trigger_info_update.py
new file mode 100644 (file)
index 0000000..7184e0f
--- /dev/null
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2014, 2015, 2016 Samsung Electronics.Co.Ltd.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+"""This script is used to update git-ref-mapping"""
+
+import os
+import sys
+import json
+
+from common.buildtrigger import trigger_info
+from common.git import Git, clone_gitproject
+from common.prerelease import is_prerelease_project
+
+GIT_FILE_NAME = 'prerelease.description'
+
+class LocalError(Exception):
+    """Local error exception."""
+    pass
+
+def main():
+    """The main body"""
+
+    saved_info = trigger_info(os.getenv('TRIGGER_INFO'))
+
+    project = saved_info.get('obs_url').split('project=')[-1]
+    if project is None:
+        raise LocalError('Please check the project (%s)' \
+                         % (project))
+    print '\n\"Title\": \"%s\"' % project
+
+    saved_info = json.dumps(saved_info)
+
+    if not is_prerelease_project(project):
+        print '%s is not prerelease project' % project
+        return 1
+
+    prjdir = os.path.join(os.getenv('WORKSPACE'), \
+                          os.path.basename(os.getenv('TEST_TRIGGER_GIT_PATH')))
+
+    if not clone_gitproject(os.getenv('TEST_TRIGGER_GIT_PATH'), prjdir, \
+                            git_cache_dir=os.getenv('GIT_CACHE_DIR')):
+        print 'Error cloning %s' % os.getenv('TEST_TRIGGER_GIT_PATH')
+        return 2
+
+    mygit = Git(prjdir)
+    mygit.checkout('master')
+    if os.path.exists(os.path.join(prjdir, GIT_FILE_NAME)):
+        mygit.remove_files(GIT_FILE_NAME)
+    with open(os.path.join(prjdir, GIT_FILE_NAME), 'w') as mf:
+        mf.write(saved_info)
+    mygit.add_files(GIT_FILE_NAME, True)
+    try:
+        mygit.commit_staged('%s' % project)
+        mygit.push(repo = 'origin', src = 'master')
+    except Exception as err:
+        print '\n** Commit or push to git error, %s\n' % err
+        return 4
+
+if __name__ == '__main__':
+    sys.exit(main())
+
index 0876990..7e27daf 100644 (file)
@@ -156,6 +156,7 @@ fi
 %{destdir}/scripts/get_git_desc_info.sh
 %{destdir}/scripts/nuget.exe
 %{destdir}/job_ref_snapshot_info_update.py
+%{destdir}/job_test_trigger_info_update.py
 %{destdir}/job_make_dep_graph.py
 %{destdir}/common/dep_graph.php.template
 %{destdir}/common/dep_graph.php.template_simple