# load the <XL_RELEASE>/conf/native files System.setProperty("com.microsoft.tfs.jni.native.base-directory", os.getcwd() + "/conf/native") if tfsServer is None: print "No server provided." sys.exit(1) if username is None: username = tfsServer['username'] if password is None: password = tfsServer['password'] if tfsServer['authenticationMethod'] == 'Ntlm': if domain is None: domain = tfsServer['domain'] credentials = NTCredentials(username, domain, password) else: credentials = UsernamePasswordCredentials(username, password) tfs_api_url = tfsServer['url'] + "/" + collectionName print "Queue build in TFS instance via this REST API: %s\r" % tfs_api_url # set up tfs tpc = TFSTeamProjectCollection(URIUtils.newURI(tfs_api_url), credentials) build_server = tpc.getBuildServer() print "Build server version: [%s]" % build_server.getBuildServerVersion() buildDefinitions = build_server.queryBuildDefinitions(teamProjectName) print "Found %s build definition(s)." % len(buildDefinitions) build_definition = build_server.getBuildDefinition(teamProjectName,
'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, configuration.password) tpc = TFSTeamProjectCollection(URIUtils.newURI(collectionUrl), credentials) workItemClient = tpc.getWorkItemClient()