본문 바로가기

open source/maven & hudson

메이븐 + 스프링 + ibatis + 허드슨 연동 구축 4탄 - 허드슨 연동 배포

나는 메이븐은 책을 보고 지금으로 부터 1년전에 공부를 했었다..

골이란게 있었고.. 페이즈란게 있었던거 같았고.. 중앙 저장소.. 사내 저장소.. 등등의 내용이 어렴풋이 기억이 난다. 그 기억을 모두 잃어버릴까 두려워 다시 공부를 한다.

허드슨은 구글 검색을 하여 대충 실습하며 동작 방식을 아주 조금 이해 했다. 메이븐과 허드슨을 사용하여 프로젝트를 구성해 보려고 한다.


4탄. 허드슨 연동 배포


-----------------------------------------------------------------------------------------------------------------


나는 centOS6 에 자바 1.6, maven 3.0.4, tomcat 6 을 설치하고 테스트를 진행했다. 


허드슨 설치 방법은 간단하다.

허드슨 다운로드 : http://eclipse.org/downloads/download.php?file=/hudson/war/hudson-3.0.0.war (나는 3.0 버전으로.)


was의 배포 디렉토리에 다운로드 한 war 파일 배포하는 방법이 있고,

다운로드한 war 파일을 실행 시키는 방법이 있다.

http://wiki.hudson-ci.org/display/HUDSON/Starting+and+Accessing+Hudson 에 가보면 실행 방법 및 옵션이 있다.기본포트는 8080 이다.

$ java -jar hudson.war
$ nohup java -jar hudson.war > $LOGFILE 2>&1


나는 톰캣에 배포했다.


1. 플러그인 설치

배포 후, 접속 첫 화면이다. 허드슨의 플러그인을 설치 할 수 있는 페이지이다. 

 



나는 기본 체크된 플러그인 3개 + SVN Publisher 만 설치하고 SKIP.... 


2. JDK, MAVEN 위치 설정

이제는 허드슨에게 JDK, MAVEN의 위치를 알려주어야 한다. 메뉴들을 보니. Hudson 관리가 있다.

Hudson 관리 > Configure system 메뉴에서 설정하기.

 




3. job 생성

새 작업 > build a free-style software project 체크 후 OK

 
 * Discard Old Builds : 체크하면 오래된 빌드는 버린다. 나는 빌드 10개까지 기록하라고 설정했다.

 * this build is parameterized : 허드슨은 빌드 프로세스에 파라미터를 제공한다.

 * Disable Build : 빌드가 실행 되지 않는다.


▶ source Code Management

 *  Repository URL : svn 주소 입력. svn://localhost/project/trunk/ 가 svn의 주소이고 MavenTest 는 프로젝트명이다.

 *  Local module directory : 만약 MavenTest 라서 설정한다면 svn://localhost/project/trunk/MavenTest 의 내용을 

                                       $HUDSON_HOME/jobs/ManenTestTrunk 경로에 MavenTest 폴더를 생성하고 그 안에 빌드를 한다.

 ........ 나머지는 생략.........






▶ Build Triggers

 * Build after other projects are built : 몇 개의 관련 프로젝트를 그룹으로 묶어서 함께 빌드한다.

 * Build periodically : SCM의 변경과 관계없이 특정 주기로 프로젝트를 빌드한다. 크론 표현식으로 지정

 * poll SCM : 특정 주기로 체크하여 SCM에 변경이 발견되면 빌드를 수행한다. 크론 표현식으로 설정


▶ Build

 * 나는 메이븐을 사용하니 메이븐으로 위와 같이 설정.


▶ Post-build Actions

 * Aggregate downstream test results : 빌드와 테스트를 다른 업무로 분리해서 빌드가 빠르게 종료될 수 있다.

 * Archive the artifacts : 허드슨 아티팩트 저장소에 추가된다.

 * Pubish Javadoc : .....  생략




4. tomcat-maven-plugin 추가하기


이제 원격으로 서버에 배포하기 위해서는 배포할 수 있는 플러그인을 추가해야한다.

pom.xml에 파일에 추가하자.


배포를 하기 위한 톰캣 플러그인

홈페이지 : http://mojo.codehaus.org/tomcat-maven-plugin/configuration.html

pom.xml에 설정 후 maven의 setting.xml 에 또 설정하여야 한다.


<plugin>

<groupId>org.codehaus.mojo</groupId>

<artifactId>tomcat-maven-plugin</artifactId>

<configuration>

<url>http://127.0.0.1:8080/manager</url>

<server>localServer</server>

</configuration>

</plugin> 


setting.xml에 설정하기


<server>

<id>localServer</id>

<username>myusername</username>

<password>mypassword</password>

</server>





[결과] 이제 svn에 commit을 하면 hudson이 svn 의 저장소에서 jobs폴더로 복사를하고 원격 톰캣서버에 배포를 한다.

 최종 pom.xml 설정

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>org.thinker.mkk</groupId>

  <artifactId>MavenTest</artifactId>

  <version>0.0.1-SNAPSHOT</version>

  <packaging>war</packaging>

<!-- 레파지토리 추가 -->

<!--  오라클과 메이븐의 라이선스 문제로 메이븐 중앙 저장소에서 받을 수 없어서-->

<repositories>

  <repository>

    <id>mesir-repo</id>

    <url>http://mesir.googlecode.com/svn/trunk/mavenrepo</url>

  </repository>

</repositories>

<!-- 레파지토리 추가 끝-->

  <build>

   <plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<configuration>

<source>1.6</source>

<target>1.6</target>

<encoding>UTF-8</encoding>

</configuration>

</plugin>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-resources-plugin</artifactId>

<configuration>

<encoding>UTF-8</encoding>

</configuration>

</plugin>

<plugin>

         <artifactId>maven-war-plugin</artifactId>

         <configuration>

         <warSourceDirectory>${basedir}/webapp</warSourceDirectory>

        </configuration>

       </plugin>

<plugin>

<groupId>org.apache.tomcat.maven</groupId>

<artifactId>tomcat6-maven-plugin</artifactId>

<version>2.0</version>

</plugin>

<!--  

배포를 하기 위한 톰캣 플러그인

홈페이지 : http://mojo.codehaus.org/tomcat-maven-plugin/configuration.html

pom.xml에 설정 후 maven의 setting.xml 에 또 설정하여야 한다.

<server>

        <id>myserver</id>

        <username>myusername</username>

        <password>mypassword</password>

</server>

-->

<plugin>

        <groupId>org.codehaus.mojo</groupId>

        <artifactId>tomcat-maven-plugin</artifactId>

        <configuration>

                <url>http://127.0.0.1:8080/manager</url>

                <server>localServer</server>

            </configuration>

</plugin>

   </plugins>

  </build>  

  

    

  <dependencies>

   <dependency>

   <groupId>org.springframework</groupId>

   <artifactId>spring-context</artifactId>

   <version>3.0.5.RELEASE</version>

   </dependency>

   <dependency>

   <groupId>org.springframework</groupId>

   <artifactId>spring-aspects</artifactId>

   <version>3.0.5.RELEASE</version>

   </dependency>

   <dependency>

   <groupId>org.springframework</groupId>

   <artifactId>spring-web</artifactId>

   <version>3.0.5.RELEASE</version>

   </dependency>

   <dependency>

   <groupId>org.springframework</groupId>

   <artifactId>spring-ibatis</artifactId>

   <version>2.0.8</version>

   </dependency>

   <dependency>

   <groupId>org.springframework</groupId>

   <artifactId>spring-webmvc</artifactId>

   <version>3.0.5.RELEASE</version>

   </dependency>

   <dependency>

   <groupId>com.oracle</groupId>

   <artifactId>ojdbc14</artifactId>

   <version>10.2.0.4.0</version>

   </dependency>

   <dependency>

   <groupId>commons-dbcp</groupId>

   <artifactId>commons-dbcp</artifactId>

   <version>20030825.184428</version>

   </dependency>

   <dependency>

   <groupId>commons-pool</groupId>

   <artifactId>commons-pool</artifactId>

   <version>20030825.183949</version>

   </dependency>

   <dependency>

   <groupId>commons-collections</groupId>

   <artifactId>commons-collections</artifactId>

   <version>20040616</version>

   </dependency>

  </dependencies>

</project>