{"id":4954,"date":"2017-05-13T21:22:34","date_gmt":"2017-05-13T21:22:34","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=4954"},"modified":"2017-06-15T11:00:42","modified_gmt":"2017-06-15T11:00:42","slug":"getting-a-ci-server-setup-using-teamcity","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/getting-a-ci-server-setup-using-teamcity\/","title":{"rendered":"Getting a CI server setup using TeamCity"},"content":{"rendered":"<p>We all use CI, right ? I&#8217;d even like to have a CI server setup at home for my own projects to at least ensure I&#8217;ve not done anything silly to tie my code to my machine or the likes, but also to ensure that I can easily recreate the build requirements of my project.<\/p>\n<p>I thought it&#8217;d be cool to get TeamCity up and running on my Linux server and (as is usual for me at the moment) I wanted it running in Docker. Luckily there&#8217;s an official build on <a href=\"https:\/\/hub.docker.com\/r\/jetbrains\/teamcity-server\/\" target=\"_blank\">Docker Hub<\/a>. <\/p>\n<p><em>Also see <a href=\"https:\/\/blog.jetbrains.com\/teamcity\/2016\/06\/teamcity-on-docker-hub-its-official-now\/\" target=\"_blank\">TeamCity on Docker Hub \u2013 it\u2019s official now!<\/a><\/em><\/p>\n<p>So first up we need to setup some directories on the host for TeamCity to store data and logs through to (otherwise shutting down Docker will lose our projects).<\/p>\n<p>First off, let&#8217;s get the Docker image for TeamCity, run<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\ndocker pull jetbrains\/teamcity-server\r\n<\/pre>\n<p>Next create the following directories (or similar wherever you prefer)<\/p>\n<p>~\/teamcity\/data<br \/>\n~\/teamcity\/logs<\/p>\n<p>Then fun the following<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\ndocker run -it --name teamcity-server  \\\r\n    -v ~\/teamcity\/data:\/data\/teamcity_server\/datadir \\\r\n    -v ~\/teamcity\/logs:\/opt\/teamcity\/logs  \\\r\n    -p 8111:8111 \\\r\n    jetbrains\/teamcity-server\r\n<\/pre>\n<p>In the above we&#8217;ll run an instance of TeamCity named <em>teamcity-server<\/em> mapping the host directories we create to the datadir and logs of TeamCity. We&#8217;ll also map the host port 8111 to the TeamCity port 8111 (host being the first of the two in the above command).<\/p>\n<p>Now if you use your preferred browser to access<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nhttp:\/\/&lt;ip-address&gt;:8111\r\n<\/pre>\n<p>You&#8217;ll be asked a couple of questions for TeamCity to set up the datadir and DB. I just used the defaults. After reading and accepting the license agreement you&#8217;ll be asked to create a user name and password. Finally supply your name\/email address etc. and save the changes.<\/p>\n<p><strong>Setting up a build agent<\/strong><\/p>\n<p>From the Agents page you can click the link Install Build Agents and either get the zip or msi and decompress the zip to a given folder or run the MSI. I&#8217;ve simply unzipped the build agent. <\/p>\n<p>We&#8217;ll need to create a buildAgent.properties file before we can run the agent. This file should be in the conf folder of the agent.<\/p>\n<p>Change the serverUrl to your TeamCity server (and anything else you might want to change).<\/p>\n<p>Now run the following on the build agent machine (I&#8217;m using Windows for the agent)<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\nagent.bat start\r\n<\/pre>\n<p>Finally click the TeamCity web page&#8217;s Unauthorized link in the Agents section and Authorize the agent. If you&#8217;re using the free version of TeamCity you can have three build agents.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We all use CI, right ? I&#8217;d even like to have a CI server setup at home for my own projects to at least ensure I&#8217;ve not done anything silly to tie my code to my machine or the likes, but also to ensure that I can easily recreate the build requirements of my project. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[102,176],"tags":[],"class_list":["post-4954","post","type-post","status-publish","format-standard","hentry","category-docker","category-teamcity"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=4954"}],"version-history":[{"count":9,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4954\/revisions"}],"predecessor-version":[{"id":5173,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/4954\/revisions\/5173"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=4954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=4954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=4954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}