Skip to content

Commit

Permalink
Merge pull request #8 from zvercodebender/master
Browse files Browse the repository at this point in the history
Adding some dashboard tiles
  • Loading branch information
Rick Broker committed Sep 24, 2019
2 parents 0414633 + 0c1d35c commit 8c47e63
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
build
temp
supervisord.*
src/test/resources/docker/bamboo/*
46 changes: 46 additions & 0 deletions src/main/resources/bamboo/CreateRelease.py
@@ -0,0 +1,46 @@
#
# Copyright 2019 XEBIALABS
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
import sys
import time
import com.xhaus.jyson.JysonCodec as json

print "Executing CreateRelease.py\n"

if bambooServer is None:
print "No server provided."
sys.exit(1)

contentType = 'application/json'
headers = {'accept' : 'application/json'}

def getProjectId(projectName):
print "Executing getProjectId() with projectName %s\n" % projectName
response = request.get('rest/api/latest/deploy/project/all', contentType=contentType, headers=headers)
for item in json.loads(response.response):
if item['name'] == projectName:
print "Project ID for %s is %s\n" % (projectName, item['id'])
return item['id']
print "Error: project not found for %s\n" % projectName
sys.exit(1)

def createRelease(projectId, planResultKey, versionName):
print "Executing createRelease() with projectId %s and versionId %s\n" % (projectId, versionName)
reqBody = '{"planResultKey" : "%s", "name" : "%s"}' % (planResultKey, versionName)
response = request.post('rest/api/latest/deploy/project/%s/version' % projectId, reqBody, contentType=contentType, headers=headers)
result = json.loads(response.response)




credentials = CredentialsFallback(bambooServer, username, password).getCredentials()
request = HttpRequest(bambooServer, credentials['username'], credentials['password'])
projectId = getProjectId(projectName)

createRelease(projectId, planResultKey, versionName)
6 changes: 0 additions & 6 deletions src/main/resources/bamboo/RunPlan.py
Expand Up @@ -7,12 +7,6 @@
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.#
#
import sys
import time
import com.xhaus.jyson.JysonCodec as json
Expand Down
9 changes: 6 additions & 3 deletions src/main/resources/bamboo/TriggerDeployment.py
Expand Up @@ -26,7 +26,8 @@ def getProjectId(projectName):
response = request.get('rest/api/latest/deploy/project/all', contentType=contentType, headers=headers)
for item in json.loads(response.response):
if item['name'] == projectName:
return item['id']
print "Project ID for %s is %s\n" % (projectName, item['id'])
return item['id']
print "Error: project not found for %s\n" % projectName
sys.exit(1)

Expand All @@ -35,7 +36,8 @@ def getEnvironmentId(projectId, environmentName):
response = request.get('rest/api/latest/deploy/project/%s' % projectId, contentType=contentType, headers=headers)
for item in json.loads(response.response)['environments']:
if item['name'] == environmentName:
return item['id']
print "Environment ID for %s is %s\n" % (environmentName, item['id'])
return item['id']
print "Error: environment not found for %s, %s\n" % (projectName, environmentName)
sys.exit(1)

Expand All @@ -44,7 +46,8 @@ def getVersionId(projectId, versionName):
response = request.get('rest/api/latest/deploy/project/%s/versions' % projectId, contentType=contentType, headers=headers)
for item in json.loads(response.response)['versions']:
if item['name'] == versionName:
return item['id']
print "Version ID for %s is %s\n" % (versionName, item['id'])
return item['id']
print "Error: version not found for %s, %s, %s\n" % (projectName, environmentName, versionName)
sys.exit(1)

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/synthetic.xml
Expand Up @@ -42,4 +42,10 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
<property name="href" category="output" />
</type>

<type type="bamboo.CreateRelease" extends="bamboo.Task">
<property name="projectName" category="input" label="Deployment project name" />
<property name="planResultKey" category="input" label="Project Build Result" />
<property name="versionName" category="input" />
</type>

</synthetic>
Expand Up @@ -10,16 +10,18 @@

bamboo:
image: atlassian/bamboo-server
volumes:
- ./bamboo:/var/atlassian/application-data/bamboo
ports:
- "54663:54663"
- "8085:8085"

xlr:
xlrbb:
image: xebialabsunsupported/xlr_dev_run:8.6.1
volumes:
- ~/xl-licenses:/license
- ./../../../../:/data
links:
- yt
- bamboo
ports:
- "5516:5516"

0 comments on commit 8c47e63

Please sign in to comment.