티스토리 뷰

Maven Pipeline item만들기

프로젝트이름과 pipeline라고 지정하고 생성한뒤

밑의 pipeline에 밑과같이 기입

pipeline {
    agent any
    tools { 
      maven 'Maven3.8.5'
    }
    stages {
        stage('github clone') {
            steps {
                git branch: 'main', url: 'https://github.com/joneconsulting/cicd-web-project.git'; 
            }
        }
        
        stage('build') {
            steps {
                sh '''
                    echo build start
                    mvn clean compile package -DskipTests=true
                '''
            }
        }
    }
}

syntax로 git 명령어를 받아올때 master이아닌 다른 브렌치의 이름을 명시하게되면 위처럼 branch에 해당 브렌치의 이름이 기입된체로 코드를 받아옵니다.

build에선

패키징과 테스트까지 스크립트로 작성된 모습

 

저장한뒤

 

jenkins- tools에서 maven을 확인해줍시다.

스크립트 tools - maven을 'Maven3.8.5'라고 명시해놨는데 위의 Maven이름과 일치하여야하니 확인

저장하고 빌드해보니 패키징까진 잘되는 모습 이제 톰켓서버에 배포까지 해보자.

 

방금 생성한 My-Third-Pipeline의 구성으로 들어가서 하단의 syntax클릭

**/*.war 모든디렉토리의 .war로 끝나는파일을 배포하겠다 명시

나의 톰켓 주소를 입력하고 스크립트를 생성하게되면 밑과같은 코드를 받을 수 있다.

deploy adapters: [tomcat9(credentialsId: 'deployer_user', path: '', url: 'http://192.168.0.96:8088')], contextPath: null, war: '**/*.war'

 

이제 My-Third-Pipeline item의 pipeline안의 코드를 수정 

pipeline {
    agent any
    tools { 
      maven 'Maven3.8.5'
    }
    stages {
        stage('github clone') {
            steps {
                git branch: 'main', url: 'https://github.com/joneconsulting/cicd-web-project.git'; 
            }
        }
        
        stage('build') {
            steps {
                sh '''
                    echo build start
                    mvn clean compile package -DskipTests=true
                '''
            }
        }
        stage('deploy'){
            steps{
                deploy adapters: [tomcat9(credentialsId: 'deployer_user', path: '', url: 'http://192.168.0.96:8088')], contextPath: null, war: '**/*.war'
            }
        }
    }
}

하나의 새로운 stage를 생성하고 deploy이며 방금 받아온 배포해주는 스크립트를 넣어준 모습

 

저장한뒤 빌드하기전 우리 톰켓사이트에 manager페이지에서 hello-world가없는지 확인하고 없다면 빌드를 해줍시다.

hello-world가 잘 생성된 모습이 확인된다.

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함