Skip to content

Commit

Permalink
Merge pull request #15 from zvercodebender/master
Browse files Browse the repository at this point in the history
New Task to check for a blocking task
  • Loading branch information
Rick Broker committed Mar 22, 2016
2 parents 7de6dde + 4be463f commit 0ed6e0c
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/resources/synthetic.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
<property name="taskTitle" category="input" label="Task Title" required="true" description="Title of the task to get the id for."/>
<property name="taskId" category="output" description="The id of the task."/>
</type>

<type type="xlr.WaitForBlockingTask" extends="xlr.XlrControlTask">
<property name="scriptLocation" default="xlr/WaitForBlockingTask.py" hidden="true" />
<property name="phaseName" label="Phase Name to check for running task" category="input"/>
<property name="taskName" label="Task Name to verify is not running" category="input"/>
<property name="pollInterval" category="input" kind="integer" label="Polling Interval" required="true" default="30" />
<property name="maxPolls" category="input" kind="integer" label="Max Polls" required="true" default="0" />
<property name="Results" category="output"/>
</type>

<type type="xlr.Server" extends="configuration.HttpConnection" />
</synthetic>
72 changes: 72 additions & 0 deletions src/main/resources/xlr/WaitForBlockingTask.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 0ed6e0c

Please sign in to comment.