- git clone https://github.com/WebGoat/WebGoat
- cd WebGoat
- docker run -it --rm --name mymaven -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven maven:3-jdk-11 mvn clean install
星期二, 1月 29, 2019
Build WebGoat in a temporary Docker Container
星期一, 12月 11, 2017
git sparse checkout
有時候我們只想拿 Git 上的一兩個檔案,但整個儲存庫很大,或歷史悠久,實在有點浪費。首先有個下指令 sparse checkout 指定要取的路徑,也可以搭配深度省略不需要的歷史:
- git init <repository_name>
- cd <repository_name>
- git config core.sparseCheckout true
- echo '/path/to/file1' > .git/info/sparse-checkout
- echo '/path/to/files/*' >> .git/info/sparse-checkout
- git remote add origin https://<repository_url>
- git pull --depth 1 origin master
- curl -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/:owner/:repo/contents/:path
- curl -H 'PRIVATE-TOKEN: <token>' https://<git_host>/api/v4/projects/:id/repository/files/<url_encoded_file_path>/raw?ref=master -o output.ext
- token 要取一個 scope 包含 api,尚在有效期限內的 personal access token
- project id 可在專案的一般設定找到,通常是個數字
- 以專案第一層 a 目錄下的 b.txt 為例,url_encoded_file_path 會是 a%2Fb.txt
- master 是分支名,也可以是 tag 或 commit id
- output.ext 是輸出檔名
星期一, 12月 04, 2017
GIT_ASKPASS timeout on Jenkins
有些 Jenkins Project 在運作一陣子之後,某天突然出現取不到 Git 原始碼(逾時)的問題,目前只找到兩個共同特徵:
- using GIT_ASKPASS to set credentials
- Jenkins node on Windows
- Command Prompt (Admin) > git config --system --unset credential.helper
星期六, 5月 13, 2017
Visual Studio Team Services + Jenkins
除了 BitBucket 以外,Visual Studio Team Services 似乎也能成為雲端免費版控服務的提供者,平時用 Visual Studio 編輯程式,持續整合時用 Jenkins 往 VSTS 取程式下來。但一開始試得不那麼順利,原來是有許多秘辛:
- VSTS 預設使用名為 Personal Access Tokens 的認證機制,不能與 Jenkins GIT_ASKPASS 相通,但若搭配 GitHub 上一個叫 Git-Credential-Manager-for-Windows 的用戶端軟體,在安裝時它會順道帶一個版本合適的 Git for Windows,省去許多麻煩。
- 在某部電腦上若已用 Microsoft Account 連過 VSTS 並有版控存取權,也裝了上述的 GCM for Windows,就可透過命令列 git ls-remote -h https://yourVSTSAccount.visualstudio.com/DefaultCollection/_git/yourProject 測通。這時由於是透過 Personal Access Tokens 認證的,所以不需輸入帳密。
- 即然不輸入帳密就能連有點不踏實,可以系統管理員身分下指令「git config --system --unset credential.helper」關閉,之後每次存取 VSTS 就要輸入帳密,而且輸入正確也沒用。
- 會慌嗎?沒事的,同樣以系統管理員身分下指令「git config --system credential.helper manager」,一切又恢復不需帳密即可存取的原樣。
- 此時可到 VSTS 網頁介面,右上角登入者的頭像下拉選單,Security -> Alternate authentication credentials -> Enable,輸入密碼兩次並儲存,未來即可在不依賴 credential.helper 的情況下存取 VSTS。
- 回到 Jenkins,GIT_ASKPASS 的條件之一就是沒有 credential.helper,所以就通了。
訂閱:
文章 (Atom)