本篇整理 Jenkins 由 TFS 取回程式編譯的一些設定細節。
開始前先要將用來登入 TFS 伺服器的 AD 帳號新增為 Credential,新增位置如下圖:
Kind 為「Username with password」,Scope 有 System 與 Global 兩種選擇,System 限定帳號只供 Jenkins 伺服器自身使用(電子郵件、與其他主機 SSH 連線),若帳號要提供建置作業使用則需選 Global,ID 欄位請輸入方便識別名稱,若不給系統會隨機命名。
接著來到設定的 TFS/Team Services 區段,在 Team Project Collections 按下 Add 新增,輸入 TFS URL,選取剛才建立的 Credential,按「Test connection」測試連線無誤後,按「Save」儲存。
設定完成後,在 Freestyle Project 設定介面的 Source Code Management 我們可以在 Team Foundation Version Control(TFVC) 的 Collection URL 下拉選單看到剛才新增的集合,Credentials 請選 Automatic 以直接引用剛才設定的帳號。
進階設定有幾個常用選項:
另外,記得在 Global Tool Configuration / MSBuild 區新增 MSBuld Installations。下圖範例為 MSBuild 2017,參考: VS2017 MSBuild 離線安裝
再來的注意事項跟 TFS Build Service 類似,為了讓 MSBuild 順利編譯各式專案,需要手動安裝所需的 SDK,這裡先列出先前整理過的問題,後面再補上本次新發現:
實作過程陸續遇到幾個新問題,一併記錄:
ASPNETCOMPILER : error ASPRUNTIME: The current identity (NT AUTHORITY/SYSTEM) does not have write access to 'C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files'.
(AspNetMerge target) -> C:/Program Files (x86)/MSBuild/Microsoft/WebDeployment/v10.0/Microsoft.WebDeployment.targets(1589,9): error MSB6004: The specified task executable location "C:/Program Files (x86)/MSBuild/Microsoft/WebDeployment/v10.0/aspnet_merge.exe" is invalid.
error MSB4019: The imported project "C:/Program Files (x86)/MSBuild/Microsoft/VisualStudio/v14.0/WebApplications/Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
、 C:/Program Files (x86)/MSBuild/14.0/bin/Microsoft.Common.CurrentVersion.targets(3266,5): error MSB3086: Task could not find "AL.exe" using the SdkToolsPath "" or the registry key "HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Microsoft SDKs/NETFXSDK/4.6/WinSDK-NetFx40Tools-x86". Make sure the SdkToolsPath is set and th e tool exists in the correct processor specific location under the SdkToolsPath and that the Microsoft Windows SDK is installed
error ASPCONFIG: Could not load file or assembly 'Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutra l, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
錯誤,需視版本需安裝報表元件: Tips of TFS connection setup in Jenkins and some hint of MSBuild and related SDK installation.