Over the limit

[Jenkins] Pipeline Script 사용하기 본문

Devops/Devops

[Jenkins] Pipeline Script 사용하기

ellapk 2024. 10. 23. 23:21

 

 

Item생성 시, type을 Pipeline으로 지정해준다.

 

 

 

pipeline {
    agent any
    stages {
        stage('Compile') {
            steps {
                echo "Compiled successfully!";
            }
        }

        stage('JUnit') {
            steps {
                echo "JUnit passed successfully!";
            }
        }

        stage('Code Analysis') {
            steps {
                echo "Code Analysis completed successfully!";
            }
        }

        stage('Deploy') {
            steps {
                echo "Deployed successfully!";
            }
        }
    }
}

 

4가지 스테이지로 구별 후, 완성 시 echo 문장만 출력하게끔 다음과 같이 script를 구성한다.

 

 

 

성공적으로 빌드되면, script의 내역들이 나타나는 것을 볼 수 있다.

 

 

    post {
      always {
        echo "This will always run"
      }
      success {
        echo "This will run when the run finished successfully"
      }
      failure {
        echo "This will run if failed"
      }
      unstable {
        echo "This will run when the run was marked as unstable"
      }
      changed {
        echo "This will run when the state of the pipeline has changed"
      }
    }
}

 

post actions와 관련된 내용을 추가하면 

 

 

 

다음과 같이 추가된 모습을 확인할 수 있다.

'Devops > Devops' 카테고리의 다른 글

[Jenkins] Delivery Pipeline  (0) 2024.10.23
Jenkins + Playbook 연동하기  (0) 2024.10.18
JAR와 WAR이해하기  (2) 2024.10.14
[Devops] Github Action란?  (1) 2024.10.13
Jenkins + Ansible 연동하기  (0) 2024.10.11