# # 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 json, sys, time from xlrhttp.HttpRequest import HttpRequest print "Executing QueueBuild" if tfsServer is None: print "No server provided" sys.exit(1) contentType = 'application/json' request = HttpRequest(tfsServer, username, password, domain) response = request.get( '%s/%s/_apis/build/definitions?api-version=2.0&name=%s' % (collectionName, teamProjectName, buildDefinitionName)) if not response.isSuccessful(): raise Exception( "Error fetching build definition. Server return [%s], with content [%s]" % (response.status, response.response)) print response.response json_response = json.loads(response.getResponse()) if json_response["count"] != 1: raise Exception( "Error fetching build definition. Server return [%s], with content [%s]" % (response.status, response.response))
# # 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 json from xlrhttp.HttpRequest import HttpRequest if tfsServer is None: print "No server provided" sys.exit(1) request = HttpRequest(tfsServer, username, password, domain) url = "%s/%s/_apis/tfvc/changesets?api-version=1.0" % (collection, project) response = request.get(url) if not response.isSuccessful(): raise Exception( "Error in getting repositories. Server return [%s], with content [%s]" % (response.status, response.response)) json_object = json.loads(response.response) commits = json_object["value"] latest_commit = commits[0] changesetId = latest_commit["changesetId"]
# # 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 com.xhaus.jyson.JysonCodec as json from tempfile import mkdtemp from xlrhttp.HttpRequest import HttpRequest print "Executing GetTfsRepoArtifacts" if tfsServer is None: print "No server provided" sys.exit(1) request = HttpRequest(tfsServer, username, password, domain) response = request.get('%s/_apis/git/repositories?api-version=1.0' % collectionName) if not response.isSuccessful(): raise Exception( "Error in getting repositories. Server return [%s], with content [%s]" % (response.status, response.response)) repository_id = json.loads(response.response)['value'][0]['id'] print "Repository id is %s" % repository_id response = request.get( '%s/_apis/git/repositories/%s/items?api-version=1.0&scopepath=%s' % (collectionName, repository_id, scopePath))
# # 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 from xlrhttp.HttpRequest import HttpRequest print "Executing CreateWorkItem" if tfsServer is None: print "No server provided" sys.exit(1) contentType = 'application/json-patch+json' request = HttpRequest(tfsServer, username, password, domain) comment_json = '{"path": "/fields/System.History", "value": "%s", "op": "add"}' % workItemComment content = '[%s]' % (comment_json) # define TFS Server url as http://server:port/tfs response = request.patch('%s/_apis/wit/workitems/%s?api-version=1.0' % (collectionName, workItemId), content, contentType=contentType) httpStatusCode = response.status if httpStatusCode == 200: print "Comment updated." else: print "Error in creating Work Item. Return status %s" % httpStatusCode print response.response sys.exit(1)
if configuration.preferredLibType == 'REST': # get the configuration properties from the UI params = { 'url': configuration.url, 'username': configuration.username, 'password': configuration.password, 'proxyHost': configuration.proxyHost, 'proxyPort': configuration.proxyPort, 'domain': configuration.domain, 'authenticationMethod': configuration.authenticationMethod } # do an http request to the server response = HttpRequest(params).get('/_apis/projectcollections', contentType='application/json') # check response status code, if is different than 200 exit with error code if response.status != 200: sys.exit(1) elif configuration.preferredLibType == 'SDK': System.setProperty("com.microsoft.tfs.jni.native.base-directory", os.getcwd() + "/conf/native") collectionUrl = configuration.url + "/" if configuration.authenticationMethod == 'Ntlm': credentials = NTCredentials(configuration.username, configuration.domain, configuration.password) else: credentials = UsernamePasswordCredentials(configuration.username,
# # Copyright 2017 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 from xlrhttp.HttpRequest import HttpRequest # get the configuration properties from the UI params = { 'url': configuration.url, 'username': configuration.username, 'password': configuration.password, 'proxyHost': configuration.proxyHost, 'proxyPort': configuration.proxyPort } # do an http request to the server response = HttpRequest(params).get(configuration.apiUrl + 'getworkspaces', contentType='application/json') # check response status code, if is different than 200 exit with error code if response.status != 200: sys.exit(1)
if configuration.preferredLibType == 'REST': # get the configuration properties from the UI params = { 'url': configuration.url, 'username': configuration.username, 'password': configuration.password, 'proxyHost': configuration.proxyHost, 'proxyPort': configuration.proxyPort, 'domain': configuration.domain, 'authenticationMethod': configuration.authenticationMethod } # do an http request to the server response = HttpRequest(params).get('/_apis/projectcollections', contentType='application/json') logger.info("Response from TFS: [%s]" % response.getResponse()) logger.info("Response status: [%s]" % response.status) # check response status code, if is different than 200 exit with error code if response.status != 200: sys.exit(1) elif configuration.preferredLibType == 'SDK': System.setProperty("com.microsoft.tfs.jni.native.base-directory", os.getcwd() + "/conf/native") collectionUrl = configuration.url + "/" if configuration.authenticationMethod == 'Ntlm': credentials = NTCredentials(configuration.username, configuration.domain,