[![logo](https://www.hongsnet.net/images/logo.gif)](https://www.hongsnet.net)

# Jenkins Source Code Deploy Overview

> GitLab Project의 Push Event 발생 시 Jenkins가 이를 배포해주는 과정을 살펴본다.

**!참고** : GitLab Webhook 설정은 생략한다. 만약 확인이 필요하다면, 다음의 링크를 참조한다.

[바로가기](./DEVOPS/WEBHOOK/)


# Jenkins Pipeline Script Configuration

> Jenkins 프로젝트 > 구성 > Pipeline 에서 설정한다.

```
pipeline {
   agent any
   
   stages {
   
      stage('Git Clone') {
            steps {
                sh 'mkdir -p hongsnet'
                dir("hongsnet")
                {
                     git branch: 'master', credentialsId: 'juhanida21', url: 'https://gitlab.hongsnet.net/joohan.hong/hongsnet.git'
                }
            }
      }
      
      stage('Source code Deploy') {
            steps {
                sh 'rsync -avz --progress hongsnet/ 172.24.0.245::HONGSNET-WEB/'
            }
      }
      
   }
}

```

# Pipeline Script Description


## Source Code Deploy 시 두 가지 Stage로 진행된다.

  - **Git Clone**
    - GitLab Project에서 master Brance를 Clone 하는 Stage 이다.
  - **Source code Deploy**
    - 홍쓰넷의 경우 소스 코드가 Storage에 위치하므로, Rsync를 이용해 업데이트 한다.

![hongsnet_deploy](./hongsnet_deploy.png)