2015年8月11日 星期二

[Maven] 基本 plugin

mvn [<goal(s)>] [<phase(s)>]

goal: <plugin>:<goal>

-- goal --
archetype:generate
    http://maven.apache.org/archetype/maven-archetype-plugin/
help:help
 
compiler:compile

    http://maven.apache.org/plugins/maven-compiler-plugin/
war:war

    http://maven.apache.org/plugins/maven-war-plugin/
jar:jar

    http://maven.apache.org/plugins/maven-jar-plugin/
dependency:help

    http://maven.apache.org/plugins/maven-dependency-plugin/
source:help

    http://maven.apache.org/plugins/maven-source-plugin/

checkstyle:checkstyle

    http://maven.apache.org/plugins/maven-checkstyle-plugin/
pmd:pmd

    http://maven.apache.org/plugins/maven-pmd-plugin/

ant:ant

    http://maven.apache.org/plugins/maven-ant-plugin/
antrun:run
    http://maven.apache.org/plugins/maven-antrun-plugin/


tomcat6/7
    http://tomcat.apache.org/maven-plugin-2.2/context-goals.html
cargo (支援多種 container 發布)
    https://codehaus-cargo.github.io/cargo/Home.html

-- phase --
clean
compile
deploy
install
test
package

2015年8月10日 星期一

[bash] 指令速記

查出 process 並用 username 過濾
ps -ef | grep username

透過 awk 篩選出 container id 並且在 docker 中移除
docker ps -a | grep imageName | awk '{print $1}' | xargs docker rm {}


篩選特定的 pid 然後 kill
ps -ef | grep ping | grep -v 'grep' |  awk '{print $2}' | xargs kill

看檔案的尾巴
tail -f

2015年8月9日 星期日

[CLI] zip/unzip, jar command

最近很常在 linux 上作業,特別是操作 weblogic 和裡面的 jar/war 檔案

原來都透過 zip/unzip 來處理檔案

常見的用法是

建立壓縮檔
zip -r zipfile.zip sourceDir

-r recursive (很好記)

解壓縮檔案 (可不加 .zip)
unzip zipfile -d targetDir

-d directory (很好記)


這樣就很方便了,不過使用 jar 可以滿足一些些虛榮心

(補)(原來之前已經寫過了,不過看起來出以前比較不會用指令)

建立壓縮檔
jar cf jarfile -C sourceDir *.class

-C 會從 sourceDir 中尋找檔案再進行建立,可以包括多個 -C

解壓縮檔案
jar xf jarfile

create
x extract
u update
t table of contents
m manifest file
f file
0 no compress (create only)
v verbose

------

以下是 man 出來的語法



2015年8月8日 星期六

[CI] svn hook & Jenkins auto build 1/2


蠻簡單的先透過 svn server 的 hook 機制 (在某些時間點觸發一些 script)

觸發 Jenkins 來啟動專案 build

而 build 本身就是依賴 maven 或是 ant 等專案的設定來啟動

--- svn ---
1. svn commit

2. 透過 svn post-commit hook 觸發 Jenkins

3. Jenkins 透過 maven 啟動編譯或發佈等行為






SET CSCRIPT=%windir%\system32\cscript.exe
SET VBSCRIPT=D:\Repositories\post-commit-hook-jenkins.vbs
SET JENKINS=http://localhost:8080/jenkins/
SET REPOS=JENKINS_JOB_NAME

"%CSCRIPT%" "%VBSCRIPT%" "%JENKINS%" "%REPOS%"
---------

post-commit-hook-jenkins.vbs



jenkins = WScript.Arguments.Item(0)
repos   = WScript.Arguments.Item(1)

url = jenkins + "job/" + repos + "/build?token=TOKEN"

Set http = CreateObject("Microsoft.XMLHTTP")
http.open "GET", url, False
http.setRequestHeader "Content-Type", "text/plain;charset=UTF-8"
http.send
crumb = null
if http.status = 200 then
  crumb = split(http.responseText,":")
end if


--- maven ---

待續