標籤:產生 ram exec egit windows 表徵圖 git bash jar hub
最近項目搬遷到公司的“GitHub”上面原來的SVN的ant發布指令碼要改下,於是百度ant擷取git的方法太少了,windows平台上更是沒有所以搞了兩天,今天終於有點成果分享給大家。
1.伺服器上也要安裝git,還要配置git環境,在Path中加上C:\Program Files (x86)\Git\cmd(你的路徑可能不同,就是Git\cmd路徑)
2.GitHub上有兩種路徑http的那個要使用者密碼,我是沒研究出來bat指令碼自動輸入密碼,所以用git開頭的路徑
3.把公開金鑰.ssh檔案夾放入C:\Users\Administrator(登入使用者對應檔案夾)下面
3.5已有公開金鑰沒有私密金鑰,
1)運行PuTTYGen(安裝TortoiseGit在其目錄下bin中),在Conversions菜單中點擊Import key,選擇ssh-keygen產生的私密金鑰檔案所在位置,比如id_rsa檔案。
2)點擊Save private key按鈕,將其儲存為.ppk檔案。
3)開啟Pageant,點擊Add Key,選擇前一步所儲存的.ppk檔案所在的位置即可。
4.雙擊啟動pageant.exe(安裝TortoiseGit在其目錄下bin中),點擊Add Key,選擇ppk檔案後開啟。伺候pageant就會在後台運行,右下角有相應表徵圖。
第一次下載用git bash 有一個yes要手動輸入以後就不用了,所以就可以用指令碼了這是一個主意點吧。
5.ant寫法先加入ant宏,放在指令碼頭上
<macrodef name = "git"> <attribute name = "command" /> <attribute name = "dir"default = "" /> <element name = "args"optional = "true" /> <sequential> <echo message = "git @{command}" /> <exec executable = "git"dir = "@{dir}"> <arg value = "@{command}" /> <args/> </exec> </sequential></macrodef><macrodef name = "git-clone-pull"> <attribute name = "repository" /> <attribute name = "dest" /> <sequential> <git command = "clone"> <args> <arg value = "@{repository}" /> <arg value = "@{dest}" /> </args> </git> <git command = "pull"dir = "@{dest}" /> </sequential></macrodef>
再寫擷取關鍵句
<git-clone-pull repository="git://github.com/280north/ojunit.git"dest="ojunit" />
這裡說明下dest="ojunit"為專案檔名字也就是和路徑最後是一樣的,擷取後和ant指令碼在一個檔案夾中
6.git的clone是全拉發布路徑要針對實際的路徑,這也是git的不好的地方(可能我是小白),還有老司機估計看出來了ant其實走的是cmd擷取git這條路,可能還有第三方jar我在github上沒找到希望有大神找到留言補充
感謝以下兩位博主給我參考:http://justlpf.blog.51cto.com/3889157/1212564
https://yq.aliyun.com/articles/44476
windows+ant+git+tomcat中ant直接擷取git項目部署注意點