Custom script run with teamcity build step

Custom script with curl rest api call to add queue doesnot seem to work in build step. Does anyone tired this option with success?

http://confluence.jetbrains.com/display/TCD7/Accessing+Server+by+HTTP#AccessingServerbyHTTP-TriggeringaBuildFromScript

curl -v --request PUT %teamcity.serverUrl%/httpAuth/action.html?add2Queue=btID&name=first.param&value=%env.value%&name=second.param=%env.val.required% -u "TCuser:TCpass"
8 comments
Comment actions Permalink

I just tried this and it worked for me. I think you need to use GET instead of PUT.

0
Comment actions Permalink

No luck. I tried with 'GET' request type to curl custom-build-step but it has not triggered my build 'B'. Could not locate in queue as well. Is there a way to debug this?. If i run curl command line by passing required param values / use http url directly in browser it triggers the build.

0
Comment actions Permalink

What does curl -v respond with? It can be an authorization issue.

0
Comment actions Permalink

Build step output shows something like below, indicating curl -v to URL specified is SU ( with exit code 0 ). I have used same credentials to connect to this teamcity server inside ant target with 'get' task corresponding to curl to check status of the build & it works fine there. Still not sure what's leading to this problem.

Starting: <TC-agent-path>/temp/agentTmp/custom_script1701710179711904932
in directory: <TC.working-dir-path>
Process exited with code 0

And to ask on linked question, I hope in build 'B' custom parameters can be retrived by defining same named configuration-parameters under 'Build parameters' & retrieving value with % ?. In this case with first.param=%first.param% . This last bit is not clear from confluence link posted above.

Thanks!.

0
Comment actions Permalink

curl -v should print the server output, including response code. And it should be visible in build log.

In build B, you can retrieve parameter from build A using the following: %dep.BuildA_Type.paramName%

0
Comment actions Permalink

For now I just disabled other 'Build Steps' and retained custom-script of running plain 'curl' to build ( no add2Queue ) & it prints server output along with response-code as like below. I think highlighted output indicates its SU?.

Also, %dep.bt<id>.param% becomes visible only if we have defined 'Snapshot Dependency' in build 'B' to depend on build 'A'. If we don't want snapshot dependency like in my case how to retrieve param-values?. I simply put /set to %param.name%. But I have not reached this point, as triggering build B with custom-script curl is not working yet....



Starting: <TC-agent-path>/temp/agentTmp/custom_script7491493468100382471
in directory: <TC.working-dir-path>
* About to connect() to <TC-Server> port <port#>
*   Trying <IP>... connected
* Connected to <TC-Server> (IP) port <port #>
* Server auth using Basic with user '<uid>'
> GET /viewType.html?buildTypeId=bt<buildID> HTTP/1.1
> Authorization: Basic <>
> User-Agent: <info>
> Host: <TC-Server>
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Tue, 15 Apr 2014
< AUTH_REDIRECT:
< Cache-Control: no-cache
< Pragma: no-cache
< Expires: 0
< Content-Length: <>
< Content-Type: text/html
   ....
   Connection #0 to host <TC-Server>  left intact

* Closing connection #0
<html><head><title>Redirection</title><META HTTP-EQUIV="REFRESH" CONTENT="0; URL=ZZZ"/><META HTTP-EQUIV=Pragma CONTENT=no-cache></head></html/>
Process exited with code 0

0
Comment actions Permalink

It's not possible to retrieve parameter from another build type, which this build doesn't have snapshot dependency (direct or indirect) to.

It also doesn't look like you are queueing a build. The correct response should include line like this:

GET /httpAuth/action.html?add2Queue=MyProject_MyBuildType HTTP/1.1
0
Comment actions Permalink

Yes, as mentioned in my response above "plain 'curl' to build ( no add2Queue ) " is run just to test curl output server response & triggering build part is taken out. Let me see more if I can spot any other thing.

0

Please sign in to leave a comment.