jenkins_podtemplate - choisungwook/portfolio GitHub Wiki

예제1 helloworld

  • busybox 이미지 사용
  • POD_LABEL is a new feature to automatically label the generated pod in versions 1.17.0 or higher

참고자료: https://github.com/jenkinsci/kubernetes-plugin#pipeline-support

podTemplate {
    node(POD_LABEL) {
        stage('Run shell') {
            sh 'echo hello world'
        }
    }
}

예제2 springboot

참고자료: https://github.com/jenkinsci/kubernetes-plugin#container-group-support

podTemplate(containers: [
    containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat')
  ]) {

    node(POD_LABEL) {
        stage('Build project') {
            git 'https://gitlab.choilab.xyz/common/springboot-commontemplate.git'
            container('maven') {
                stage('Build a Maven project') {
                    sh 'mvn package'
                }
            }
        }
    }
}

참고자료

⚠️ **GitHub.com Fallback** ⚠️