REST API authentication


We use a third party deployment (ControlTier) server get our builds out to our app servers.  One of the way we use is it is to kick off a build from their via REST API url to kick off the build and then wait until the build is finished to run the deployment.  The problem I'm having is that the call to http://{server}/httpAuth/action.html?add2Queue={build ID} is that it's not liking the authentication of the user that is being triggered via an SSH call through Cygwin.  The error is: 'HTTP Authorization failure.'  I've tried passing the username and password as part of the URL but that's not working either.

Is there a way to create a user account that would work in this manner?


Comment actions Permalink

Hi Jay,

Not sure I fully understand the authentication issue here. Authentication for the HTTP request to TeamCity is not related to SSH user, etc. You need to provide username and password of a valid TeamCity user with at least "developer" role in the related project and provide that via HTTP BASIC authentication method.

Also, it is recommended to use REST API to trigger the build instead of obsolete "add2Queue" method.

You can find all the details at the doc page.

Comment actions Permalink

The problem with the SSH is that it is trying to login in as {username:password}@{server} instead of the LDAP name.  Like I said earlier, I've tried adding the credentials of a user I created with admin and developer permissions to the URL and that still didn't work:

Getting: http://builduser:build@{server}/httpAuth/action.html?add2Queue={build ID}

Here's the output of the script:

Start: "Run the coordinated end-to-end the build and deployment processes across the configured Builders and Sites."

commands: Build,Update begin workflow command (1/2) -> "Build -resourcename .* -resourcetype [^\.]*" ..


Getting: http://builduser:build@{server}/httpAuth/action.html?add2Queue={build ID}

To: c:\ctier\ctl\projects\dealmaker\modules\CIUpdater\commands\null1168306205

Error handler caught failed command execution: Test-head[CIUpdater]#Build. reason: The following error occurred while executing this line:

c:\ctier\ctl\projects\dealmaker\modules\CIUpdater\commands\Build.xml:69: HTTP Authorization failure

Looking at the REST API info you sent, to trigger a build you need to pass it an XML file with the build configuration info in it?   Is that correct?

Comment actions Permalink

What we need to do in order to move this functionality off of our old CI engine (CruiseControl) is to be able to complete the following workflow on TeamCity:

  1. kick off a build via a http call
  2. if build is successful, continue on with the deploy process
  3. if build fails, end workflow

The 1st issue we have is the authentication from calling from a non-AD user via SSH through the http call.  
Comment actions Permalink


> Looking at the REST API info you sent, to trigger a build you need to pass it an XML file with the build configuration info in it?   Is that correct?

Right. Ther are some examples in the doc on that.

> calling from a non-AD user via SSH through the http call.

Sorry, this does not  make sense to me so far.

I'd suggest using a singple tool like curl to send HTTP calls directly to TeamCity HTTP port and continue from that once you get it working.

Comment actions Permalink

It is a cURL call that hits the build configuration but the problem is the authentication of the service account.  We're using LDAP authentication with TC but this call is done w/ SSH connection using Cygwin on Windows with the service account that's trying to kick off the build is a local user and not part of Active Directory.  

I've tried a few things that hasn't worked yet:

  1. Creating a user account for the service account in TC
  2. Passing the credentials in the URL both of a local user account
  3. Passing of my account credentials to test

Would turning on the guest account & granting it permissions on the builds work?

Comment actions Permalink


I've been playing around with this again and regardless of the user I set it to, I can't get it to authenticate.  I created a new user called builduser and tried it again and here's the message I'm seeing in debug mode:

[2015-06-30 15:59:07,386]  DEBUG [; http-nio-80-exec-8] - Processing request with no authorization header: GET '/httpAuth/action.html?add2Queue=Linear_Head_Clustered', from client, user-agent Java/1.6.0_16, no associated user
[2015-06-30 15:59:07,386]  DEBUG [; http-nio-80-exec-8] - Matched authentication scheme: jetbrains.buildServer.controllers.interceptors.auth.impl.AgentHttpAuthenticationScheme, authResult: UNAUTHENTICATED
[2015-06-30 15:59:07,387]  DEBUG [; http-nio-80-exec-8] - Responding with 401 HTTP status with message "Unauthorized: "Authorization" header is not specified", sending header in response: WWW-Authenticate: Basic realm="TeamCity"

I'm not sure why if I specify the info in "http://builduser:build@qtscotc01/httpAuth/action.html?add2Queue=Linear_Head_Clustered" as the URL.
Comment actions Permalink


A bit of a late comment on this: the logging suggests there is no "Authorization" header in the request, which means basic HTTP authentication is not forced by your client.

Let me note that you still use unsupported way of triggering builds. For the recommended way check link to the REST oc above.


Please sign in to leave a comment.