본문 바로가기
개인공부/배포

미니 피씨의 젠킨스를 이용한 ci/cd 작업 - 젠킨스 와 docker-compose Jenkins pipeline (4)

by 응가1414 2023. 9. 2.

젠킨스 Jenkins 미니피씨에 로컬로 설치하기

설치는 블로그를 돌아다니면서 설치하세요

https://docs.3rdeyesys.com/dev-tools/ncloud-dev-tools-jenkins-server-install-guide-centos.html

모든 곳의 설치하는 과정은 많이 있어요 저는 Jenkins pipelinepipeline script 쉡스크립트 만 보여드릴꺼에요

1. 젠킨스 (Jenkins) pipeline script 설정

Docker와 docker-compse을 설치를 하세요

저와 같이 설치를 하고 실행을 하세요 이유는 아직 모르겠습니다.... 그냥되서 좋게 생각하고 공부를 더해야될꺼 같아요

 

 pipeline {
     agent any
     tools {
         nodejs 'nodejs' // 이 부분에서 설정한 도구 이름 사용, 노드 도구 설치한것
     }
     stages {
         stage('github clone') {
             steps {
                 git branch: '클론하고싶은branch이름', credentialsId: 'init_king_nuri_ID', url: '클론하고싶은repository이름 적기'
             }
         }
         
         stage('frontend-nextjs-build'){
             steps{
                    dir('frontend'){
                         sh'''
                             echo ========frontend-nextjs-build-start========
                             npm install
                             npm run build
                         '''
                 }
             }
         }
         
         stage('backend-spring-boot-3-build'){
             steps{
                 dir('backend'){
                     dir('spring-boot-3'){
                          sh'''
                               echo ========backend-spring-boot-3-build-start========
                               ./gradlew bootJar
                           '''
                     }
                 }
             }
         }
         
         stage('docker-compose build'){
             steps{
                 sh 'docker-compose up -d --build'
                 sh 'docker-compose ps'
             }
         }
     }
 }
 ​

pipeline {
    agent any
    tools {
        nodejs 'nodejs' // 이 부분에서 설정한 도구 이름 사용, 노드 도구 설치한것
    }
    stages {
        stage('github clone') {
            steps {
                git branch: 'release', credentialsId: 'init_king_nuri_ID', url: 'https://github.com/dmdrk1414/NCT'
            }
        }
        
        stage('frontend-nextjs-build'){
            steps{
                   dir('frontend'){
                        sh'''
                            echo ========frontend-nextjs-build-start========
                            npm install
                            npm run build
                        '''
                }
            }
        }
        
        stage('backend-spring-boot-3-build'){
            steps{
                dir('backend'){
                    dir('spring-boot-3'){
                         sh'''
                              echo ========backend-spring-boot-3-build-start========
                              ./gradlew bootJar
                          '''
                    }
                }
            }
        }
        
        stage('docker-compose build'){
            steps{
                sh 'docker-compose stop'
                sh 'docker-compose up -d --build'
                sh 'docker-compose ps'
            }
        }
    }
}