kok202
Jenkins 기초

2019. 6. 18. 19:51[정리] 기능별 개념 정리/Jenkins

1. https://jenkins.io/download/ 에서 jenkins.war 파일 설치

 

2. jenkins.war 파일의 옵션 명령어 조회

java -jar jenkins.war --help

 

3. jenkins.war 파일 실행

java -jar jenkins.war --httpPort=7070 --ajp13Port=-1

 

4. http://localhost:7070 으로 접속해서 jenkins GUI 실행

젠킨스가 관리자에 의해서 설치되었는지 확인하기 위해 인증 정보를 요구한다.

 

5. 인증 비밀번호 확인하고 입력

cat ~/.jenkins/secrets/initialAdminPassword

 

6. Select plubins to install 선택

플러그인에 git, gihub 을 체크해서 설치

왜인지는 모르겠는데 maven 을 발견 못했다

maven 으로 빌드할 경우 Ant와 Gradle은 필요없으므로 체크 해제

 

7. 설치 실행

 

8. Jenkins 관리자 계정 생성

 

9. Jenkins 재시작 후 로그인

java -jar jenkins.war --httpPort=7070 --ajp13Port=-1

Jenkins 로그인 : http://localhost:7070/login?from=%2F

 

 

 

 

 

 


10. 프로젝트에 접속

Jenkins 관리 -> 플러그인 설정 -> 설정 가능 탭 -> Maven Integration 검색 후 설치

 

 

 

11. 새 작업 생성 -> maven 프로젝트로 생성

git ->Repository URL 에 깃허브 저장소 주소를 입력

git -> Credentials 에 깃허브 저장소에 접근하기 위한 깃허브 계정 등록

 

- Root POM : 깃허브 저장소의 pom.xml 위치에 맞게 상대 주소로 맞춰준다

- maven 버전 명시 해주는 설정을 위해  'the tool configuration' 링크를 타고 이동

 

적당한 메이븐 버전 추가

빌드에 필요한 JDK 도 추가 이 과정에서 오라클 아이디/비밀번호 필요

여기까지하고 일단 저장한다.

 

 

 

 

 

 


12. 빌드가 완료되면 WAS 에 파일을 이동시켜야한다.

수동으로 매번 옮기기 번거로우니 '빌드 후 조치' 를 이용하여 빌드 완료시 파일 이동을 자동화하자

그런데 '빌드 후 조치'에 완료시 파일 이동을 시켜주는 기능이 없다.

 

13. 플러그인을 설치하자 : Jenkins 관리 -> 플러그인 설정 -> 설정 가능 탭 -> Deploy to container 검색 후 설치

 

14. 이전에 만든 작업 'test' 를 수정하자

젠킨스 메인 -> test 선택 -> 구성

다시 빌드 후 조치 추가를 눌러서 Deploy war/ear to a container 가 추가됬음을 확인한다.

어떤 파일을 옮길지 지정하고 WAS 에서 WAS 접근일 위해 만들어둔 계정을 입력해준다.

ex. Tomcat WAS -> tomcat-users.xml 가 아래와 같을 경우 jenkinsDeployment/123456789

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
              
    <!--
    NOTE:  By default, no user is included in the "manager-gui" role required
    to operate the "/manager/html" web application.  If you wish to use this app,
    you must define such a user - the username and password are arbitrary.
    -->

    <!--
    NOTE:  The sample user and role entries below are wrapped in a comment
    and thus are ignored when reading this file. Do not forget to remove
    <!.. ..> that surrounds them.
    -->

    <!--
    <role rolename="tomcat"/>
    <role rolename="role1"/>
    <user username="tomcat" password="tomcat" roles="tomcat"/>
    <user username="both" password="tomcat" roles="tomcat,role1"/>
    <user username="role1" password="tomcat" roles="role1"/>
    -->

    <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <role rolename="manager-status"/>
    <user username="jenkinsDeployment" password="123456789" roles="manager-gui,manager-script,manager-status"/>

</tomcat-users>

 

 

 


15. 빌드 시작을 눌러서 빌드를 해본다.