젠킨스 버전업이 이루어지면서 내부적으로 jdk 11 을 이용하게 되었다.

이때 젠킨스를 이용한 빌드시에 사용하는 remote 패키지가 11로 컴파일된거라 구버전의 젠킨스에서 빌드하던 jdk 8버전의 프로젝트들은 빌드시 remote.jar(jdk 11) 실행에 실패하면서 빌드가 실패나버린다.(내용은 버전 맞지 않음)

 

그럼 어떻게 해야할까?

 

우선 젠킨스자체의 메이븐 빌드 로 아이템을 만들지 말고, 프리스타일로 만든뒤

 

쉘로 직접 빌드하게 해주면되긴한다. 

 

쉘환경이 jdk 8 이면된다.

좀더 설명하면

 

1. jenkins build job 생성시 메이븐이아니라 프리스타일로 생성

2. 생성시 만들어진 이름으로, 빌드실행하면 젠킨스의 빌드노드 홈의, workspace 디렉토리 이하에 그 빌드아이템의 방이 생김

3. 해서... 우선 스크립트(execute shell) 는 비워두고 git 등의 정보를 입력하여 item 을 만들고, 그 item 을 빌드하면 생성한 item 이름으로 디렉토리가 생김. 

4. 그 디렉토리안에 보면 git 의 내용을 clone 해온걸 볼 수 있음

5. 여기서 단순히 jar 빌드이면 mvn 명령으로 빌드시킬수 있도록 직접 테스트 해보고 빌드 잘 되는 쉘 명령어를 item 의 execute shell 에 넣어주면됨.

6. 여기서 만약, 빌드 노드에 settings.xml 이 없다면 원래는 젠킨스의 아이템 생성시 메이븐 설정에 provided settings.xml 항목에 임의의 xml 을 정의해서 그걸 빌드에 사용하게 하는데, 우리는 쉘에서 하는거라 직접해줘야한다.

7. 해서 간단히, 해당 git 안에 그 프로젝트에 맞는 settingsl.xml 을 만들고 거기에 설정 넣어둔뒤 execute shell 실행시 실행될 mvn 옵션으로 -s settings.xml   처럼 맞는 xml 을 넣어주면된다.

 


아주 간단히 풀어보자.

우선 설명하자면 프로젝트 생성시에 메이븐 프로젝트 ...에 대한 뭔가를 할 필요는 없다.

이런게편한거지; 예제로는 Jackson 라이브러리를 메이븐을 통해서 관리한다고 가정하고 진행한다.


1. 프로젝트 가장 밖에 pom.xml  을 생성하자.

2. http://maven.apache.org/pom.html 내용을 보고

The Basics

The POM contains all necessary information about a project, as well as configurations of plugins to be used during the build process. It is, effectively, the declarative manifestation of the "who", "what", and "where", while the build lifecycle is the "when" and "how". That is not to say that the POM cannot affect the flow of the lifecycle - it can. For example, by configuring the maven-antrun-plugin, one can effectively embed ant tasks inside of the POM. It is ultimately a declaration, however. Where as a build.xml tells ant precisely what to do when it is run (procedural), a POM states its configuration (declarative). If some external force causes the lifecycle to skip the ant plugin execution, it will not stop the plugins that are executed from doing their magic. This is unlike a build.xml file, where tasks are almost always dependant on the lines executed before it.

<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.codehaus.mojo</groupId>
  <artifactId>my-project</artifactId>
  <version>1.0</version>
</project>

내용을 참고하여 빈 pom.xml 을 만들어보자. 이때 groupId 나 artifiactid , 버전 등은 알아서 수정해라.


3. http://wiki.fasterxml.com/JacksonDownload 에 가서 Jackson 1.x 에 대한 저장소 정보를 가져다가 붙여라.

현재 버전은 아래와 같이 되어있더라.

<repositories>
  <repository>
   <id>codehaus-snapshots</id>
   <url>http://snapshots.repository.codehaus.org</url>
  </repository>
 </repositories>

 <dependencies>
  <dependency>
   <groupId>org.codehaus.jackson</groupId>
   <artifactId>jackson-mapper-asl</artifactId>
   <version>1.9.11</version>
  </dependency>
 </dependencies>



4. 해당 파일을 저장하고 마우스 오른쪽 눌러서 가장 아래에 있는 Add As Maven... 을 선택한다.

그러면 자동으로 긁어와서 external lib 에 들어가 있는걸 확인할 수 있다.

만약 안나온다면 오른쪽에 탭으로 줄여져 있는 Maven Project 를 선택해서 탭을 확장한뒤에 로그를 봐도 된다.

(에러가 난다면 왜 나는지 등의 로그를 확인 가능하다 )



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

call by ref ? value?  (0) 2013.06.21
intellij 한글 깨짐 (톰캣서버 돌릴때...)  (0) 2013.04.16
intelliJ 에서 개뱔해보기...  (2) 2012.12.31
javadoc... linke  (0) 2012.10.18
실행가능한 jar 묶기  (0) 2012.03.07

+ Recent posts