# Azure DevOps, Teams 與 IntelliJ 整合協作開發 ###### tags: `azure` `devops` `teams` `IntelliJ` `工作筆記` 為了符合專案政策,一切的開發活動都會在 [Azure DevOps](https://dev.azure.com/) 上進行,故 安裝 [Azure DevOps IntelliJ 外掛程式](https://plugins.jetbrains.com/plugin/7981-azure-devops)。 ## IntelliJ 安裝 建議使用 [JetBrains Toolbox](https://www.jetbrains.com/toolbox-app/) 安裝。 ## 使用 Azure Repos 原始碼儲存庫 ### 方法一: 將既有的 git repo 與 Azure Repos 關聯 在原本的 sts 專案目錄下執行: ```shell git remote add azure https://chte@dev.azure.com/chte/<PROJECT>/_git/<REPO> # 例如: git remote add azure https://chte@dev.azure.com/chte/fia-its/_git/sts ``` ### 方法二: Clone From Azure DevOps via plugin `File > New > Project from Version Control...` ,選擇 `Azure DevOps Git`,接著按 [Clone]  點 [Sign in...]:  將產生的代碼貼到連結的 https://microsoft.com/devicelogin 網頁中:  #### 組織衝突處理 請切換到 [Team Foundation Server] 頁籤,並切換 [Switch server] 到中華的組織https://dev.azure.com/chte 就可以了:  ### 方法三: 直接從 Azure DevOps clone 如果上述兩種方法都不行,很可能是遇到了 [Azure DevOps plugin 的 bug](https://github.com/microsoft/azure-devops-intellij/issues/428),有前人試出了這條血路: 1. 到 https://dev.azure.com/chte/_usersSettings/tokens 產生一組 Full Access 的 token,並好好記下來,以後無法從網頁上再查詢。 2. 使用 git clone 專案,記得一定要用 `https` 協定,並且使用 `chte` 帳號: ```shell git clone https://chte@dev.azure.com/chte/<PROJECT>/_git/<REPO> ``` 3. 詢問密碼時輸入 token - 如果密碼輸入錯了,請看 `git config credential.helper` 查詢的值是什麼,如果是 `manager` 或 `manager-core` 可以去 Windows 的「認證管理員」裡面修正。 ## 環境設定 ### 確認專案 SDK `File > Project Structure... > Project Settings > Project`,接著在右邊選單 Project SDK 中點選: `+ Add SDK` > `Download JDK` > `1.8` > `AdoptOpenJDK HotSpot 版本` ### Proxy 若是有需要在 proxy 後進行開發,請注意 proxy 需手動定義 url, 不可用 自動偵測 pac 的方式 > 節錄: > I have experienced the same issue just now connecting via our corporate proxy. Login using proxy auto-detect setting doesn't work but the workaround of specifying the proxy url manually works fine and I'm able to log in. > 來源:[issuecomment](https://github.com/microsoft/azure-devops-intellij/issues/89#issuecomment-774994510) ## 使用 Azure Artifacts 管理共用函式庫 ### Maven `settings.xml` 編輯 `~/.m2/settings.xml`,增加透過 Azure Artifacts 存取第三方 jar 的設定。 PS. 一般本機預設的.m2會安裝在使用者帳號底下,如果有自訂的路徑但又忘記在哪裡,請至`File` > `Settings` > `Maven` 裡查看  #### 建立 Azure DevOps 的 Access Token 請至 https://dev.azure.com/chte/_usersSettings/tokens 建立一組 Access Token,賦予 `Read` 權限:  :::spoiler Azure DevOps 官方參考文件 https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page ::: #### 編輯 Maven 設定檔 並設定 `~/.m2/settings.xml` 如下: ```xml <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <servers> <server> <id>[專案-feed]</id><!-- 例如 fia-its-feed, bli-dass-feed ---> <username>chte</username> <password>[你的 Access Token]</password> </server> </servers> </settings> ``` #### 編輯 Maven 設定檔 (上包 OA 網路) 如果是在上包 OA 網路裡,請在 `~/.m2/settings.xml` 加入 proxy 設定如下: ```xml <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- 在上包 OA 網段使用,請加以下 proxy 設定 --> <proxies> <proxy> <id>cht-oa-http-proxy</id> <active>true</active> <protocol>http</protocol> <host>proxy.cht.com.tw</host> <port>8080</port> <nonProxyHosts>192.168.*|10.*</nonProxyHosts> </proxy> <proxy> <id>cht-oa-https-proxy</id> <active>true</active> <protocol>https</protocol> <host>proxy.cht.com.tw</host> <port>8080</port> <nonProxyHosts>192.168.*|10.*</nonProxyHosts> </proxy> </proxies> </settings> ``` #### 更新 IDE 內的 Maven 專案 > 在專案目錄中點選 `pom.xml`,右鍵選單 `Maven` > `Reload Project` > 在專案目錄中點選 `pom.xml`,右鍵選單 `Run Maven` > `clean install` ## 整合開發環境 ### Create Pull Request via plugin Azure DevOps 在 Git 視窗中的 Pull Requests 頁籤 點選 <kbd>+</kbd>,即可透過 Azure devOps plugin 完成 Create PR 。 ### Pull Requests  自行建立的 PR 單會在 Pull Requests 頁籤下面的 `Requested by me` 列出清單 若有被團隊同仁在 PR 指定為 Reviewer 則會於 該視窗下方的 `Assigned to me` 列出清單 > 若有需求,可在 PR 右鍵將該 PR 放棄(abandon) ### Work Items (上傳圖片失敗,....需要再補圖....) 會列出預設列出 `Assigned to me` 的工作項目,點選後會在 web 開啟該工項的詳述說明。 也可以列出 `Followed work items` 的工作項目。 > 可以在工項右鍵選單 `create a branch`,將該工項與 `branch` 綁定 ### Build status  只要 push (branch or commit),會自動觸發 build 的 job,並且可在 Intellij IDEA 右下角看到最後一次 build 的狀態 > 綠色打勾則為正常健康狀態 > 紅色則在 build 的過程發生錯誤,可點選 view details 回到 web 查看細節 ## 問題排解 #### 登入後看不到 Repos 怎麼辦?  Ans: 人員加入 Azure DevOps 預設的 access level 是 `Stakeholder`,權限較低,需要再請組織管理人員調整為 `Basic`。 (`Basic` 會有費用產生,每人每月 NT$180,所以管理會比較嚴格一點,要和PM申請) #### 開發環境切換 例如 sdg 與 sts Ans: * 基本上不同的 REPO 就等同於不同專案,因此對於 Intellij IDEA 而言就當作是 New Project 或者 New Windows * 另以 sts 與 sdg 的關係為,sdg 是 fork from sts ,若熟悉 git 操作,則可以將 sts 設定到 sdg 的 remote 中。可參考[使用 Azure Repos 原始碼儲存庫的方法一](#使用-Azure-Repos-原始碼儲存庫)。 :::info To SDG's PG:切換專案,視同為重新 New Project。 ::: ## Microsoft Teams 整合 https://azuredevopslabs.com/labs/vstsextend/teams/
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.