From 4be463f3f285aae2e6c02cfa930819a5475afae6 Mon Sep 17 00:00:00 2001 From: Rick Broker Date: Mon, 21 Mar 2016 17:44:02 -0500 Subject: [PATCH] New Task to check for a blocking task Added a new task (WaitForBlockingTask). The new tasks check for a specific task in a phase of any release. --- build.gradle | 2 +- src/main/resources/synthetic.xml | 9 +++ src/main/resources/xlr/WaitForBlockingTask.py | 72 +++++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/xlr/WaitForBlockingTask.py diff --git a/build.gradle b/build.gradle index 58c16d6..fce7bd1 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id "com.github.hierynomus.license" version "0.11.0" } -version="1.7.1" +version="1.7.2" apply plugin: 'java' apply plugin: 'idea' diff --git a/src/main/resources/synthetic.xml b/src/main/resources/synthetic.xml index a1cd22d..53cab97 100644 --- a/src/main/resources/synthetic.xml +++ b/src/main/resources/synthetic.xml @@ -49,6 +49,15 @@ + + + diff --git a/src/main/resources/xlr/WaitForBlockingTask.py b/src/main/resources/xlr/WaitForBlockingTask.py new file mode 100644 index 0000000..159d173 --- /dev/null +++ b/src/main/resources/xlr/WaitForBlockingTask.py @@ -0,0 +1,72 @@ +# +# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS +# FOR A PARTICULAR PURPOSE. THIS CODE AND INFORMATION ARE NOT SUPPORTED BY XEBIALABS. +# + +import sys, string, time +import com.xhaus.jyson.JysonCodec as json +from datetime import date + +xlrUrl = xlrServer['url'] +xlrUrl = xlrUrl.rstrip("/") + +credentials = CredentialsFallback(xlrServer, username, password).getCredentials() + +xlrAPIUrl = xlrUrl + '/api/v1/releases' + + +#server = { 'url': xlrServer['url'], 'username': username, 'password': password, 'proxyHost': proxyHost, 'proxyPort': proxyPort} +#request = HttpRequest(server, username, password) + +phase = getCurrentPhase() +task = getCurrentTask() + +isRunning = True +pollCount = 0 + +while isRunning == True : + pollCount = pollCount + 1 + isRunning = False + request = XLRequest(xlrAPIUrl, 'GET', None, credentials['username'], credentials['password'], 'application/json').send() + releases = json.loads(request.read()) + + print "Http Status: %s" % request.status + if request.status == 200: + for release in releases: + #print "Release = %s" % (release["title"]) + for phase in release["phases"]: + #print ">>> Phase = %s" % (phase["title"]) + if phase["title"] == phaseName: + for task in phase["tasks"]: + if task["title"] == taskName : + print ">>>***id = %s, title = %s***" % ( task["id"], task["title"] ) + print " Status = %s " % ( task["status"] ) + if task["status"] == "IN_PROGRESS" : + isRunning = True + break + # End if + # End for + # End if + if isRunning == True : + break + # End for + if isRunning == True : + break + # End for + else: + print "Failed to connect at %s." % URL + response.errorDump() + #sys.exit(1) + # End if + if isRunning : + time.sleep( pollInterval ) + if pollCount >= maxPolls : + if maxPolls > 0: + print "Max Polls reached. Exiting" + sys.exit(1) + # End if + # End if + print "Is Running? %s " % (isRunning) +# End while +sys.exit(0)