Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems publishing artifacts to remote TeamCity server on IIS

Tags:

iis

teamcity

arr

I have a rather strange problem with TeamCity. I have a TeamCity installation, with local and remote build agents. The TeamCity server is hidden behind IIS with Application Request Routing (ARR), to enable SSL, etc. I have a feeling this might be part of the problem, but I am not sure. Another reason to suspect IIS being part of the problem is, I tried to host TeamCity on an Azure Web App, and got exactly the same behaviour.

The trouble is, after building, when the build agents try to publish the artifacts to the server, I get a 404 back from the TeamCity server. TeamCity thinks it is a recoverable error (see log), and keeps trying again some times. Eventually, the publishing fails.

If I configure the local agents to access TeamCity via http://localhost, everything works smooth. But, when accessing via the public address (which is served via IIS), I get 404s. The 404 content looks like a standard IIS 404 page.

I have tries setting agent logging verbosity to DEBUG, but it still doesn't output the actual URL it is trying to call.

Does anyone have any clues on how to troubleshoot this? Getting the TeamCity agent to output the URL for which it gets the 404 would be a good start.

[Publishing artifacts] Publishing 1 file [F:/tc/ba3/temp/buildTmp/out/_PublishedWebSites/**/* => dist.zip] using [WebPublisher]
[15:34:15][Publishing artifacts] Publishing 1 file [F:/tc/ba3/temp/buildTmp/out/_PublishedWebSites/**/* => dist.zip] using [ArtifactsCachePublisher]
[15:35:10]
[Publishing artifacts] Recoverable problem publishing artifacts (will retry): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">;
<html xmlns="http://www.w3.org/1999/xhtml">;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>404 - File or directory not found.</h2>
  <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
 </fieldset></div>
</div>
</body>
</html>
like image 454
Erik A. Brandstadmoen Avatar asked Aug 04 '15 13:08

Erik A. Brandstadmoen


2 Answers

EDIT: Found this documented on the TeamCity pages as well:

https://confluence.jetbrains.com/display/TCD9/Known+Issues#KnownIssues-FailuretopublishartifactstoserverbehindIISreverseproxy

Failed Request Tracing (as Terri Rougeou Donahue mentioned) was the tool to help me. I had two errors.

  1. Firstly, the StaticFileHandler was not turned off. So, when trying to POST to the /httpAuth/artefactUpload.html URL, the StaticFileHandler tried to handle the request before ARR could handle it.
  2. When I turned off StaticFileHandler, the RequestFiltering module kicked in, and returned an error code of 404.13, which is "Content Length Too Large". After a bit of googling, I found this, http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits, describing the parameter maxAllowedContentLength, and says "The default value is 30000000, which is approximately 28.6MB."

The solution was:

  1. Turn off StaticFileHandler for the web site (Handler mappings)
  2. Edit the properties of "Request filtering" settings on the Web site, set "Maximum allowed content length" to something sensible. I added a 0 (makes it approximately 286MB, as artifacts can get quite large).

maxContentLength IIS settings window

like image 95
Erik A. Brandstadmoen Avatar answered Dec 14 '22 11:12

Erik A. Brandstadmoen


You could enable Failed Request Tracing on the IIS server that TeamCity is deploying to. This would provide the location where the 404 is occuring.

like image 33
Terri Rougeou Donahue Avatar answered Dec 14 '22 11:12

Terri Rougeou Donahue