Jenkins高级篇之Pipeline

时间:2023-02-02 22:45:02

Jenkins高级篇之Pipeline

 

1、基础调试,配置正常,执行也正常。

 Jenkins高级篇之Pipeline

2、配置springboot项目。

 Jenkins高级篇之Pipeline

Jenkins高级篇之Pipeline

 

pipeline配置语句: 

pipeline {

    agent any

    stages {

        stage('Checkout') {

            steps {

                echo 'Checkout'

                checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '0064fe57-ebdf-4285-82e8-661e74b2bb8d', url: 'git@gitee.com:suno/springboot.git']]])

            }

        }       

        stage('Build') {

            steps {

                echo 'Building'

                sh '''

                export JAVA_HOME=/usr/local/jdk1.8.0_161

                /usr/local/apache-maven-3.5.4/bin/mvn clean package -Dmaven.test.skip=true

                '''

            }

        }

        stage('Test') {

            steps {

                echo 'Testing'

                sh '/usr/local/apache-maven-3.5.4/bin/mvn clean'

            }

        }

        stage('Deploy') {

            steps {

                echo 'Deploying'

                sh 'sh -x ./update.sh'

                sh '''

                export JAVA_HOME=/usr/local/jdk1.8.0_161

                /usr/local/apache-maven-3.5.4/bin/mvn clean package

                '''

            }

        }

    }

}

 

在Jenkins上面提前配置好:credentialsId: '0064fe57-ebdf-4285-82e8-661e74b2bb8d'。