kubernetes pipeline

一: Kubernetes 安装pipeline插件

Jenkins 在kubernetes 平台完成pinpeline ,必须先安装Pipeline 等插件!

选择manager Plugins

 

安装pinline插件

 

 

 

创建一个job

 

显示有一个流水线,说明,pipeline 已成功安装

 

 

 

二: 创建测试的pipeline 项目

创建一个test

流水线

 

在最下的pipelin 执行pipeline script

 

 

 

 

 

 

 

测试一下,先将模板的语法拷贝出来

pipeline {

   agent any

 

   tools {

      // Install the Maven version configured as "M3" and add it to the path.

      maven "M3"

   }

 

   stages {

      stage('Build') {

         steps {

            // Get some code from a GitHub repository

            git 'https://github.com/jglick/simple-maven-project-with-tests.git'

 

            // Run Maven on a Unix agent.

            sh "mvn -Dmaven.test.failure.ignore=true clean package"

 

            // To run Maven on a Windows agent, use

            // bat "mvn -Dmaven.test.failure.ignore=true clean package"

         }

 

         post {

            // If Maven was able to run the tests, even if some of the test

            // failed, record the test results and archive the jar file.

            success {

               junit '**/target/surefire-reports/TEST-*.xml'

               archiveArtifacts 'target/*.jar'

            }

         }

      }

   }

}

把没用的语法删除

 

保存进行构建

pipeline {

   agent any

   stages {

      stage('1.拉取代码') {

         steps {

          echo 'Hello World'

         }

        }

        stage('2.代码编译') {

   steps {

           echo 'Hello World'

           }

 }

stage('3.代码测试') {

   steps {

           echo 'Hello World'

           }

        }

    }

}

 

 

构建测试

 

构建成功