Do not perform the job if any queued item in the same job exists 37/118537/1
authorJunghyun Kim <jh0822.kim@samsung.com>
Mon, 13 Mar 2017 05:37:00 +0000 (14:37 +0900)
committerJunghyun Kim <jh0822.kim@samsung.com>
Mon, 13 Mar 2017 05:37:00 +0000 (14:37 +0900)
This job performs branch-project mappings for all git repos.
Therefore, it is okay to perform only the last job.
To do this, I added code to check 'queueItem' in this job.

Change-Id: I3ebfb1c1ba17d93412d58db658d93d513d7ddc64
Signed-off-by: Junghyun Kim <jh0822.kim@samsung.com>
job_update_git_branch_project_mapping_for_dashboard.py

index cd67fea..735930c 100644 (file)
@@ -24,6 +24,7 @@ import subprocess
 from common.utils import sync
 from common.git_obs_mapping import GitObsMapping
 from common.git import clone_gitproject
+from jenkinsapi.jenkins import Jenkins
 
 #================================================================================
 # generate_mapping()
@@ -76,6 +77,22 @@ def generate_mapping(prjdir, target_dir):
 #exit(0)
 
 ###########################################################
+# if next job exists, just return.
+jenkins = Jenkins(os.getenv("JENKINS_URL"),
+                  os.getenv("OBS_API_USERNAME"),
+                  os.getenv("OBS_API_PASSWD"))
+job = os.getenv('JOB_NAME')
+
+url = os.path.join(os.getenv("JENKINS_URL"),
+                  "job",
+                  job,
+                  "api/python")
+job_data = jenkins.get_data(url)
+if job_data["queueItem"] is not None:
+    print "Another queued job exists. exiting..."
+    exit(0)
+
+###########################################################
 # main
 WORKSPACE = os.getenv('WORKSPACE', '.')
 MAPPING_PRJ = os.getenv("MAPPING_PRJ", "scm/git-obs-mapping")