본문 바로가기
IT/CICD

Ant 유용한 Tip-1

by 마이오픈마인드 2022. 3. 13.

1. Ant를 이용하여 svn 에 소스 commit 하는 방법

 

   서버환경에서 ant를 이용하여 svn repository에 소스를 commit 할 수 있다.  

   하기 예제는  사전에 리눅스 서버에 svn repository 프로젝트가 checkout 된 경우이다.  

 

    - jenkins job에서 svn checkout 받은 케이스

    ex). svn.co.dir = /work/ci/jenkins/workspace/dev_openmind_build/svn_repo_project

     - jenkins job 경로 : /work/ci/jenkins/workspace/dev_openmind_build/   
     - jenkins job에서 svn 프로젝트 checkout 받은 경로 : svn_repo_project

  

1.1 특정 파일 commit

<target name='copy2File' depends='make2File'>
    <echo> copy2File start </echo>

    <copy file='${build.output.dir}/file.zip' todir='${svn.co.dir}/lib' verbose='true'/>     // svn checkout 받은 위치로 commit할 file복사 
    <echo> copy2File end </echo>
</target>

<target name='svnCommitFile' depends='copy2File'>
    
    <exec executable='/bin/sh' dir='${svn.co.dir} outputproperty='result_upgrade'>
         <arg value='-c' />
         <arg value='svn upgrade' />
    </exec>
    <echo>   upgrade result message : ${result_upgrade} </echo> 
    
    <exec executable='/bin/sh' dir='${svn.co.dir} outputproperty='result_commit'>
         <arg value='-c' />
         <arg value='svn commit ./lib/file.zip -m "zip commit" --username ${svn.username} --password ${svn.password} ' />
    </exec>
    <echo>   commit result message : ${result_commit} </echo>


</target>

 

1.2 특정 디렉토리 변경분 commit

<exec executable='/bin/sh' dir='${svn.co.dir} outputproperty='result_upgrade'>
         <arg value='-c' />
         <arg value='svn upgrade' />
    </exec>
    <echo>   upgrade result message : ${result_upgrade} </echo> 
    
    <exec executable='/bin/sh' dir='${svn.co.dir} outputproperty='result_commit'>
         <arg value='-c' />
         <arg value='svn commit ./lib/* -m "changed commit" --username ${svn.username} --password ${svn.password} ' />
    </exec>
    <echo>   commit result message : ${result_commit} </echo>

 

2. SVN서버 => Remote서버 접속이 필요할 경우  

 

     2.1 Remote 서버 작업을 위한 환경 구성(jsch-0.1.55.jar)

         ant 스크립트에서  및 sftp 파일전송이 필요할때 유용하게 사용할 수 있다. 

            - remote서버의 명령어 실행(shell 호출)       

            - remote서버의 파일 전송(File2File)

         

         2.1.1 다운로드 

             하기 환경에서 jsch-0.1.55.jar 파일 다운로드가 가능하다. 

             - 사이트 : Download jsch JAR 0.1.55 ➔ With all dependencies! (jar-download.com)

 

Download jsch JAR 0.1.55 ➔ With all dependencies!

com.jcraft jsch 0.1.55 compile group: 'com.jcraft', name: 'jsch', version: '0.1.55' //Thanks for using https://jar-download.com libraryDependencies += "com.jcraft" % "jsch" % "0.1.55" //Thanks for using https://jar-download.com jsch Rate from 1 - 5, Rated

jar-download.com

       

         2.1.2 설정방법

             ant엔진 설치경로의 lib폴더에 해당 라이브러리(jsch-0.1.55.jar) 업로드 하면 된다. 

             - 라이브러리 업로드 폴더 : $ANT_HOME/lib

 

         2.1.3 사용 가능한 ant task

              세팅이 완료되면 하기 ant task를 사용할 수 있다. 

              - scp

              - sshexec

 

3. ant로 java compile이 메모리 부족할 경우 

    3.1 ant 파일 ANT_OPT 추가 

           - $ANT_HOME/bin

           - 파일명 : ant

           - 추가 내용 : 

show_help=false

export ANT_OPTS="-Xms1024m -Xmx8192m -Xss64m"    // ANT_OPTS 내용 추가 

if [ -z "$PROTECT_NL" ]; then 
    PROTECT_NL=true

 

 

 

'IT > CICD' 카테고리의 다른 글

Ant script 구성방법 및 샘플(build.xml, build.properties)  (0) 2022.03.11
maven 다운로드 및 설치  (0) 2022.03.10
Ant 다운로드 및 설치  (0) 2022.03.10
Jenkins plugin 세팅  (0) 2022.03.10
Jenkins 다운로드 및 설치  (0) 2022.03.10