ãã®èšäºã§ã¯ãKaspersky Labã®å人ãéå§ãããµã€ã¯ã«ãç¶ç¶ããMicrosoftã®ãã¹ãããŒã«ã䜿çšããå®éã®çµéšïŒããã³ããã ãã§ã¯ãããŸããïŒãæšå¥šäºé ãšçµè«ãšãšãã«èª¬æããŸãã èè ã¯ããã¹ããšã³ãžãã¢ã§ããIgor ShcheglovitovïŒ@ the ins4n3 on the hubïŒã§ãã ãã¹ãèšäºã«ã¯#mstestingã®ã¿ã°ãä»ããŠããŸãã
ãã®èšäºã§ã¯ãAzureã®ä»®æ³ãã·ã³äžã§ã人æ°ã®ããTeamCityã·ã¹ãã ã䜿çšããŠç¶ç¶çã€ã³ãã°ã¬ãŒã·ã§ã³ããã»ã¹ãèšå®ããæåã®çµéšãå ±æããããšæããŸãã ç§ãã¡ã®ã·ã¹ãã ã¯ãã€ã§ã䟿å©ã«ã¢ã¯ã»ã¹ã§ãããªãœãŒã¹ãå¶åŸ¡ã§ãããããããã¯è¯ãããšã§ãã
以äžã®ã¢ã¯ã·ã§ã³ã«ã€ããŠèª¬æããŸãã
- TeamCityãµãŒããŒã®æ§æã
- ã¯ã©ãŠããšãŒãžã§ã³ãã®ã€ã¡ãŒãžãäœæããŸãã
- ããŒã«ã«gitã®ã»ããã¢ããã
- Azureã§Webãµã€ããäœæãã
- ãã«ãèšå®
- ã¯ã©ãŠããšãŒãžã§ã³ãã®è¿œå ãšå®è¡
- äœæ¥ãã§ãã¯
é çªã«å§ããŸãããã
TeamCityãµãŒããŒã®æ§æ
TeamCity-serverãæ°ããä»®æ³ãã·ã³ã«å±éããŸãã
Azureã§æ°ããVMãäœæããŸãã
ããŒã80ãéããŸãïŒTeamCityãµãŒããŒã§äœ¿çšãããŸãïŒã
Azureã³ã³ãœãŒã«çµç±ã§VMã«æ°ãããã£ã¹ã¯ãè¿œå ããŸãïŒTeamCityãµãŒããŒã䜿çšããŠããŒã¿ãä¿åããŸãïŒã
RDPãä»ããŠäœæãããVMã«æ¥ç¶ãã TeamCityãã£ã¹ããªãã¥ãŒã·ã§ã³ãããŠã³ããŒãããŸã
ãã£ã¹ã¯ã®ç®¡çãéããæ°ãããã£ã¹ã¯ãåæåããŸãã
ãµãŒããŒã³ã³ããŒãã³ãã®ã¿ãéžæããããã»ã¹ã§ãTeamCityãã€ã³ã¹ããŒã«ããŸãã
次ã«ãTeamCityããŒã¿ãã£ã¬ã¯ããªãšããŠãæ°ãããã£ã¹ã¯ãæå®ããŸãã
TeamCityãµãŒããŒã®ããŒããèšå®ããŸãïŒ80çªç®ã®ããŒãã䜿çšããŸãïŒ
ãããŠãTeamCityãµãŒãã¹ãåäœãããŠãŒã¶ãŒãéžæããŸãïŒã·ã¹ãã ãæå®ããŸããïŒ
ã€ã³ã¹ããŒã«åŸã httpïŒ// localhost / mntãéããèªåãµãŒããŒæ§æã®ããã»ã¹ãéå§ããŸãã
[ç¶è¡]ãã¿ã³ãã¯ãªãã¯ããåŸãTeamCityããŒã¿ããŒã¹ã®ã¿ã€ããéžæããŸãïŒãã®äŸã§ã¯ãå éšããŒã¿ããŒã¹ã䜿çšããŸãïŒã
次ã«ãããŒã¿ããŒã¹ã®åæåãéå§ãããŸãããã®åŸãTeamCityãµãŒããŒç®¡çè ãäœæããå¿ èŠããããŸãã
FWã§ããŒã80ãéããŸãã
ã¯ã©ãŠããšãŒãžã§ã³ãã€ã¡ãŒãžã®äœæ
JetBrainsã¯ãå°ãåã«ãAzureã§TeamCityã¯ã©ãŠããšãŒãžã§ã³ããèªåçã«äœæããŠå®è¡ã§ãããã©ã°ã€ã³ãçºè¡šããŸããã ãã®ãã©ã°ã€ã³ã䜿çšããŠãšãŒãžã§ã³ããèµ·åãããšãæ°ããä»®æ³ãã·ã³ãäœæãããŸãã ãã€ã§ãã¯ã©ãŠããšãŒãžã§ã³ããåæ¢ã§ããŸããããã«ããããªãœãŒã¹ã解æŸãããããã«å¿ããŠã³ã¹ããåæžãããŸã:)ã¯ã©ãŠããšãŒãžã§ã³ãã䜿çšããŸãã ã¯ã©ãŠããšãŒãžã§ã³ãã¯ãä»®æ³ãã·ã³ã®äºåã«æºåãããã€ã¡ãŒãžã«åºã¥ããŠäœæãããŸãã
ã ããïŒ
Azureã§æ°ããä»®æ³ãã·ã³ãäœæããŸãã Visual Studio 2013ã§äœæãããASP.NETãµã€ãã®ãã«ããäœæããMsTestã䜿çšããŠãã¹ããå®è¡ããŸãã ä»ã®ããŒã«ã䜿çšã§ããŸããã ããã¯éèŠã§ã¯ãããŸããã ãšãŒãžã§ã³ãã«Visual Studioãã€ã³ã¹ããŒã«ããå¿ èŠããããŸãïŒCommunity 2013ãã€ã³ã¹ããŒã«ããŸãããç¡æã®ãµãã¹ã¯ãªãã·ã§ã³ããæã¡ã®å Žåãä»®æ³ãã·ã³ã®ã£ã©ãªãŒã§ã¯ãã¹ã¿ãžãªããã¬ã€ã³ã¹ããŒã«ãããã€ã¡ãŒãžãèŠã€ãããªããããæåã§ã€ã³ã¹ããŒã«ããå¿ èŠããããŸãïŒã
ããŒã9090ãéãå¿ èŠããããŸããããã¯ããšãŒãžã§ã³ãããªãã¹ã³ããããã©ã«ãã®ããŒãã§ãã
RDPãä»ããŠãäœæãããVMã«æ¥ç¶ããŸãã Git for WindowsãããŠã³ããŒãããŠã€ã³ã¹ããŒã«ããŸã ã ã€ã³ã¹ããŒã«äžã«ãWindowsã³ãã³ãããã³ããã®[Gitã䜿çšãã]ãã§ãã¯ããã¯ã¹ããªã³ã«ããŸãã
TeamCityãµãŒããŒã®ããŒããæå®ããŸã
ãšãŒãžã§ã³ããã©ã¡ãŒã¿ãèšå®ããŸãã
serverUrl -TeamCityãµãŒããŒã®ã¢ãã¬ã¹
workDir ããã³
tempDirã¯ããã©ã«ãã§æ®ãããšãã§ããŸããããããã®å€æ°ã«ã¯éåžžãVMã§ç¹å¥ãªãã£ã¹ã¯ïŒäžæã¹ãã¬ãŒãžïŒã䜿çšããŸãã
FWãŸãã¯æ¬¡ã®ã³ãã³ãã䜿çšããŠãçä¿¡æ¥ç¶çšã«ããŒã9090ãéããŸãã
netsh advfirewall firewall add rule name = " TeamCityAgent In" dir = in action = allow protocol = TCP localport = 9090
ã¯ã©ãŠããšãŒãžã§ã³ããäœæããåŸïŒVMãèµ·åããç¬éããïŒãåæå段éã§ãã³ã°ããTeamCityãµãŒããŒã«æ¥ç¶ããŸããã ãããããããã¯JetBrainsãã©ã°ã€ã³èªäœã®æè¡çãªå®è£ ã®ãã°ã§ãããããŸã åé¡ãããå¯èœæ§ããããŸãã ãã ããRDPãä»ããŠãšãŒãžã§ã³ãã«æ¥ç¶ãããšãŒãžã§ã³ããµãŒãã¹ãæåã§åèµ·åãããšããšãŒãžã§ã³ãã¯æ©èœããŸãã ãã®ããã»ã¹ãèªååããããšã«ããŸããã ãããéåžžã«ç°¡åã«è¡ãæ¹æ³ã®äŸã次ã«ç€ºããŸãã
ããŒã«ã«ã°ã«ãŒãããªã·ãŒãšãã£ã¿ãŒã¹ãããã€ã³ïŒgpedit.mscïŒãéããŸã
æ°ããã¹ã¿ãŒãã¢ããPowerShellã¹ã¯ãªãããè¿œå ãã
get-service "TeamCity Build Agent" | restart-service -PassThru
次ã«ãããŒã¿ã«ãä»ããŠVMãåæ¢ããããã«åºã¥ããŠä»®æ³ãã·ã³ã®ã€ã¡ãŒãžãäœæããå¿ èŠããããŸãã
ãã®åŸãVMãåé€ããŸãã
ããŒã«ã«GITãæ§æãã
GitHubã§æ°ãããªããžããªãäœæããŸãã
ããã«ãªã³ã¯ãã³ããŒããŸãïŒ
ããŒã«ã«ã³ã³ãã¥ãŒã¿ãŒã«GITãã€ã³ã¹ããŒã«ããŸãïŒãããããã§ãã¯ãçæãããŸãïŒã ã³ãŒããªããžããªã®ããŒã«ã«ã³ããŒãšããŠæ©èœããæ°ãããã©ã«ããŒãäœæããŸãã ãã®åŸãããŒã«ã«ãã©ã«ããŒãGitHubã«æ¥ç¶ããŸããã³ãã³ãã©ã€ã³ã䜿çšããŠãäœæãããã©ã«ããŒã«ç§»åããgit clone {gitRepositoryUrl}ã³ãã³ããå®è¡ããŸãã
äŒæ¥ãããã¯ãŒã¯ããäœæ¥ããŠããå Žåããããã·ã®åé¡ãåå ã§ã¯ããŒã³ã³ãã³ãã倱æããããšããããŸãã äŒæ¥ã®ãããã·ãªã¯ãšã¹ãããªãã€ã¬ã¯ãããããŒã«ã«NTLMãããã·ãµãŒããŒãã€ã³ã¹ããŒã«ããã ãã§ããã®éä¿¡ã®åé¡ãæ§æããã³åé¿ããããšãã§ããŸããã ãããã·é åžãããã¯ããã«ãããŸã ã
æ§æãæ£åžžã«å®äºããããGitã®ãããã·ãæ§æããå¿ èŠããããŸãããããè¡ãã«ã¯ã次ã®ã³ãã³ããå®è¡ããŸãã
git config --global http.proxy localhost ïŒ{cntlm-proxy-port}
git config --global https.proxy localhost ïŒ{cntlm-proxy-port}
ãããžã§ã¯ããã©ã«ããŒïŒGITïŒã§ãªããžããªãè€è£œããåŸãVisual Studioã§æ°ãããœãªã¥ãŒã·ã§ã³ãäœæããå¿ èŠããããŸãïŒASP.NET Webãã©ãŒã ãããžã§ã¯ã+ UnitTestProjectïŒ
ã¹ã¿ãžãªã§ã³ããããšããã·ã¥ã®å€æŽãå®è¡ããŸãã
ãã®åŸãæ°ãããã§ãã¯ã€ã³ãGitHubã«è¡šç€ºãããŸãã
泚ïŒã³ãã³ãã©ã€ã³ã§gitã³ãã³ãã䜿çšããŠå€æŽãã³ãããããããšãã§ããŸã
git addã ïŒGitãªããžããªã«ãã¡ã€ã«ãè¿œå ããŸãïŒ
git commit âamãã³ãããã®ãã¹ããïŒå€æŽã®ã³ãããïŒ
git push {git-url}ïŒå€æŽãããŒã«ã«ã¹ãã¬ãŒãžããGitHubã«ããã·ã¥ïŒ
Azureã§Webãµã€ããæ§ç¯ãã
Azureã³ã³ãœãŒã«ããæ°ãã空ã®Webãµã€ããäœæãã
ãµã€ããäœæãããã[ããŒãžã§ã³ç®¡çã·ã¹ãã ã§å±éãæ§æ]ãªã³ã¯ãã¯ãªãã¯ããGitHubãªããžããªãæ°ãããµã€ãã«ãªã³ã¯ããŸãã
ãµã€ãã®èšå®ãéããŸãã [èšå®]ã¿ãã§ã¯ã次ã®ããšã«èå³ããããŸãã
URL git ã¢ãã¬ã¹
å±éãéå§ãã URL ã¢ãã¬ã¹
æåã®URLã§deployãcifromgittestsite.gitã«çœ®ãæããåãåã£ããªã³ã¯ãgit pushã³ãã³ãã«æž¡ããšãWebãµã€ãã®ãããã€ã¡ã³ããèµ·åããã³ãã³ããååŸãããŸãã
git.exe push -f address
次ã«ãGitHubããã®èªåå±éããªãã«ããŸãã ãããè¡ãããªãå Žåãåãã§ãã¯ã¯ãµã€ãã®èªåå±éã«ã€ãªãããŸãã ãããŠãç§ãã¡ã®ç®æšã¯CIãå®è£ ããããšã§ããã³ãŒããæ£åžžã«ã¢ã»ã³ãã«ããããŠããããã¹ããå®è¡ãããå Žåã«ã®ã¿å±éãå®è¡ããŸãã
ãã«ãèšå®
TeamCity UIïŒhttpïŒ// TeamCityServerDnsïŒãéããæ°ãããããžã§ã¯ããäœæããŸãïŒãããžã§ã¯ãã®äœæïŒã
ãããžã§ã¯ãåãèšå®ããŸãã æ°ãããã«ãæ§æãè¿œå ãã
æ§æåãæå®ããŸã
VCSïŒããŒãžã§ã³ç®¡çã·ã¹ãã ïŒãæ§æããŸãã ããã§ãVCSïŒGitïŒã¿ã€ããååããã§ããURLïŒãªããžããªã®URLã®ã¿ãèªã¿åãããªããžããªã¢ã¯ã»ã¹ãªã³ã¯ããgitã®httpsãŸãã¯httpãããã³ã«ã«æ³šæããŠãã ããïŒãå ¥åãããã©ã³ãïŒãã¹ã¿ãŒã®ã¿ãäœæããŸããïŒãæå®ãããã¹ãgitã«èšå®ããå¿ èŠããããŸãããšãŒãžã§ã³ãã®exe
æ§æåŸãTestConnectionãã¯ãªãã¯ããŠãGitHubãªããžããªãŒãžã®æ¥ç¶ã確èªã§ããŸã
CheckOutãªãã·ã§ã³ã§VCSãæ£åžžã«æ§æããåŸãVCSãã§ãã¯ã¢ãŠãã¢ãŒã-ãšãŒãžã§ã³ãã§èªåçã«æå®ããŸãã
[ãã«ãã¹ããã]ãéžæãããã«ãã®ã¹ããããè¿œå ïŒãã«ãã¹ãããã®è¿œå ïŒããŸãã
æåã®ã¹ãããã¯ããœãªãŠã·ã³ãçµã¿ç«ãŠãããšã§ãã ããã§ã¯ãç»é¢äžã®ããã«ãã¹ãŠãå ¥åããå¿ èŠããããŸãã
2çªç®ã®ã¹ãããã¯ããã¹ããå®è¡ããããšã§ãã
3çªç®ã®æé ã¯å±éã§ãïŒå±éããŒã ã¯ãµã€ãã®ã»ããã¢ããããã»ã¹ã§åœ¢æãããŸããïŒ
次ã®ãããªãã®ãåŸãããã¯ãã§ãã
æ°ããããªã¬ãŒãäœæããŸãã ããã§ã¯ããã§ãã¯ã€ã³ããšã«ãã«ããããªã¬ãŒããããã¯ã¹ããªã³ã«ããŸãã
ã¯ã©ãŠããšãŒãžã§ã³ãã®è¿œå ãšèµ·å
TeamCityãµãŒããŒã䜿çšããŠãRDPçµç±ã§ä»®æ³ãã·ã³ã«æ¥ç¶ããŸãã ã¯ã©ãŠããšãŒãžã§ã³ãã管çããããã®ãã©ã°ã€ã³ãããŠã³ããŒãããŸã ã
ãã©ã°ã€ã³ãFïŒ\ pluginsãã©ã«ããŒïŒFãã©ã€ãã¯TeamCityDataDirectoryïŒã«å ¥ããTeamCity ServerãµãŒãã¹ãåèµ·åããŸãã
TeamCity UIãéããŸãïŒã¡ãã¥ãŒ[管ç] => [ãã©ã°ã€ã³ãªã¹ã]ïŒã
æ°ããAzure çµ±åãã©ã°ã€ã³ããã©ã°ã€ã³ã®ãªã¹ãã«è¡šç€ºãããã¯ãã§ã
次ã«ãAzureã³ã³ãœãŒã«ãä»ããŠæ°ãã空ã®ã¯ã©ãŠããµãŒãã¹ãäœæããŸããããã¯ãTeamCityãšãŒãžã§ã³ãã€ã³ã¹ã¿ã³ã¹ãæ ŒçŽããããã®ãªããžããªãšããŠæ©èœããŸãã
[管ç] => [ã°ããŒãã«èšå®]ã«ç§»åããæ£ããå®å šãªTeamCity DNSãµãŒããŒãèšè¿°ããŸãã
æ°ããã¯ã©ãŠããšãŒãžã§ã³ããããã¡ã€ã«ã®äœæã«ç§»ããŸãããã管ç=>ãšãŒãžã§ã³ãã¯ã©ãŠã=>æ°ãããããã¡ã€ã«ã®äœæ
ããã§ãAzureãµãã¹ã¯ãªãã·ã§ã³ãããããã¡ã€ã«åãã¯ã©ãŠãã¿ã€ã-Azureã管ç蚌ææžãããã³SubscriptionIdãèšå®ããå¿ èŠããããŸãïŒãã®ããŒã¿ã¯https://manage.windowsazure.com/publishsettingsããããŠã³ããŒãã§ããŸã ïŒ
ã¡ã€ã³ãããã¡ã€ã«èšå®ãå ¥åãããã[ã€ã¡ãŒãžã®è¿œå ]ãã¯ãªãã¯ããŠãã¯ã©ãŠããšãŒãžã§ã³ãä»®æ³ãã·ã³ã®ã€ã¡ãŒãžã®ååã空ã®ã¯ã©ãŠããµãŒãã¹ã®ååããšãŒãžã§ã³ãã®æ倧æ°ããšãŒãžã§ã³ãã®ãµã€ãºãäœæããããšãŒãžã§ã³ãã®ååã®ãã¬ãã£ãã¯ã¹ãæå®ããŸã
ã泚æ ãšãŒãžã§ã³ãã€ã³ã¹ã¿ã³ã¹ã®æ° ã¯ãä»®æ³ãšãŒãžã§ã³ãã®ã¯ã©ãŠãã€ã¡ãŒãžäžã® ãã¡ã€ã¢ãŠã©ãŒã« 㧠éããŠãã ããŒã ã®æ°ã«äŸåããŸã ã
äŸ ïŒ ããã©ã«ãã®ããŒãããšãŒãžã§ã³ãã«æå®ãããŠããå Žåãã€ãŸã 9090ã ãã¡ã€ã¢ãŠã©ãŒã« ã§ããŒã9090ã®ã¿ãéã ã å Žå ãäœæã§ãããšãŒãžã§ã³ãã¯1ã€ã ãã§ãããã€ã¡ãŒãžã«9090-9099ã®ç¯å²ãããå Žåã 10åã®ãšãŒãžã§ã³ããäœæã§ããŸãã
èšå®ãä¿åãããšãTeamCityã¯æ°ããã¯ã©ãŠããšãŒãžã§ã³ããèªåçã«èµ·åããŸãã
ãšãŒãžã§ã³ã管çã¡ãã¥ãŒãšãŒãžã§ã³ã=>ã¯ã©ãŠããšãŒãžã§ã³ãããšãŒãžã§ã³ãã管çã§ããŸãã
ãšãŒãžã§ã³ãã¯ãèµ·åæã«ä»®æ³ãã·ã³ãèªåçã«äœæããŸãã
äœæ¥ç¢ºèª
ãã¹ãŠãäœæããã³æ§æãããŸãã ããã§ããã«ãã®ãã§ãã¯ãéå§ã§ããŸãã
ãããè¡ãã«ã¯ãããããžã§ã¯ããã¡ãã¥ãŒã§ãå®è¡ããã¯ãªãã¯ããŸã
ãã«ãã®ãã°ãèŠããšãã³ãŒããGitHubããããŠã³ããŒãããããã«ãããããŠããããã¹ããéå§ãããŸãããã¹ãŠãæåãããšããããã€ãéå§ãããŸãã
ãã«ãããªã¬ãŒãã€ãŸã githubã«æ°ããå€æŽãã³ããããããšã
ãã®åŸããã«ãã¯æ°åã§èªåçã«éå§ãããŸã-ãã«ãã¯èªåçã«ãã«ãããããã¹ããå®è¡ãããAzureã®ãµã€ããèªåçã«ã·ã£ããããŠã³ãããŸã