現在在測試新的Devpos環境, 以現有使用TFS的經驗,Azure Devops Server 2019 自然是第一個考慮的工具。
把Azure Devops Server 2019 的安裝比較沒什麼問題,基本上安裝程式會檢查環境,有缺什麼會顯示出來。例如:要先安裝SQL SERVER;要有JDK(沒有的話,打個勾勾會自動裝OpenJDK) 。 這個比遙遠的當年 TFS 2005 裝了好幾天才裝起來好太多了 。
不過安裝好之後,要在pipelines建第一個部署群組就卡關了,"部署群組"就是要部署到哪裡去,被部署的SERVER上面要裝一個代理程式( agent) 。
But… 安裝agent,居然是叫你自己下powershell command的方式。虧我前面還在誇Azure Devops Server 2019的安裝介面做的不錯。
雖然在介面上他己經產生好script,把他貼到powershell裡面去執行就好了。看起來一塊蛋榚啊!! 介面長的像這樣
照畫面上的指示,把那一堆Script放到powershell的command裡執行
結果
哇哩,反覆的仔細檢查script.
才發現179字元 “Administrator” 有問題, 把 “ ” 換成正常的 " 。
再來一次
PS C:\> $ErrorActionPreference="Stop";If(-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() ).IsInRole( [Security.Principal.WindowsBuiltInRole] "Administrator")){ throw "在系統管理員 PowerShell 提示字元處執行命令"};If($PSVersionTable.PSVersion -lt (New-Object System.Version("3.0"))){ throw "指令碼 (3.0) 需要的 Windows PowerShell 最低版本,與目前正在執行的 Windows PowerShell 版本不符。" };If(-NOT (Test-Path $env:SystemDrive\'azagent')){mkdir $env:SystemDrive\'azagent'}; cd $env:SystemDrive\'azagent'; for($i=1; $i -lt 100; $i++){$destFolder="A"+$i.ToString();if(-NOT (Test-Path ($destFolder))){mkdir $destFolder;cd $destFolder;break;}}; $agentZip="$PWD\agent.zip";$DefaultProxy=[System.Net.WebRequest]::DefaultWebProxy;$securityProtocol=@();$securityProtocol+=[Net.ServicePointManager]::SecurityProtocol;$securityProtocol+=[Net.SecurityProtocolType]::Tls12;[Net.ServicePointManager]::SecurityProtocol=$securityProtocol;$WebClient=New-Object Net.WebClient; $Uri='https://go.microsoft.com/fwlink/?linkid=2066756';if($DefaultProxy -and (-not $DefaultProxy.IsBypassed($Uri))){$WebClient.Proxy= New-Object Net.WebProxy($DefaultProxy.GetProxy($Uri).OriginalString, $True);}; $WebClient.DownloadFile($Uri, $agentZip);Add-Type -AssemblyName System.IO.Compression.FileSystem;[System.IO.Compression.ZipFile]::ExtractToDirectory( $agentZip, "$PWD");.\config.cmd --deploymentgroup --deploymentgroupname "first" --agent $env:COMPUTERNAME --runasservice --work '_work' --url 'http://172.16.1.111/' --collectionname 'DefaultCollection' --projectname 'uuuu' --auth Integrated; Remove-Item $agentZip;
目錄: C:\azagent
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 2019/6/17 下午 03:18 A1
>> 連線:
正在連線到伺服器...
>> 註冊代理程式:
正在掃描工具功能。
正在連接至伺服器。
請輸入 代理程式的部署群組標記? (Y/N) (請為 否 按 Enter) >
已成功新增代理程式
正在測試代理程式連線。
2019-06-17 07:22:07Z: 已儲存設定。
請輸入 要用於服務的使用者帳戶 (請為 NT AUTHORITY\SYSTEM 按 Enter) >
正在將檔案權限授與 'NT AUTHORITY\SYSTEM'。
已成功安裝服務 vstsagent.172.TEST
服務 vstsagent.172.TEST 已成功設定復原選項
服務 vstsagent.172.TEST 已成功設定為延遲自動啟動
已成功設定服務 vstsagent.172.TEST
已成功啟動服務 vstsagent.172.TEST
終於可以註冊上去了,握拳!!
同場加映:如何移除 agent
從上面的script可以發現,他其實只做2件事,
- 下載1個zip 檔,然後解壓縮到C:\azagent\A1
- 執行裡面的config.cmd 跟著一堆參數
所以要移除agent , 一樣用有管理員身分的powershell到C:\azagent\A1 裡執行 config.cmd 只是參數換成remove
PS C:\azagent\a1> .\config.cmd remove
正在移除服務
正在等候服務結束...
成功:正在移除服務
正在從伺服器移除代理程式
請輸入 驗證類型 (請為 Integrated 按 Enter) >
正在連線到伺服器...
成功:正在從伺服器移除代理程式
正在移除 .credentials
成功:正在移除 .credentials
正在移除 .agent
成功:正在移除 .agent
沒有留言:
張貼留言