一、第一个pipeline

pipeline { 
    agent any
    stages { 
        stage('Build') { 
            steps { 
                echo 'Building..' 
                } 
            } 
            stage('Test') { 
                steps { 
                    echo 'Testing..' 
                } 
            } 
            stage('Deploy') { 
                steps { 
                    echo 'Deploying....' 
                } 
            } 
             stage('Deploy1') { 
                steps { 
                    echo 'Deploying1....' 
                } 
            } 
        }
    }

运行结果:
在这里插入图片描述

二、通过Pipeline运行多个exe程序

pipeline {
    agent any
    stages {
        stage('Run EXE Programs1') {
            steps {
                bat '''
                    echo Running multiple EXE programs...
                    "C:\\ProgramData\\Jenkins\\.jenkins\\workspace\\PipelineTestExe1\\ConsoleApp1.exe"
                    '''
            }
        }
         stage('Run EXE Programs2') {
            steps {
                bat '''
                    echo Running multiple EXE programs...
                    "C:\\ProgramData\\Jenkins\\.jenkins\\workspace\\PipelineTestExe2\\ConsoleApp1.exe"
                    '''
            }
        }
         stage('Run EXE Programs3') {
            steps {
                bat '''
                    echo Running multiple EXE programs...
                    "C:\\ProgramData\\Jenkins\\.jenkins\\workspace\\PipelineTestExe3\\ConsoleApp1.exe"
                    '''
            }
        }
    }
}

运行结果:
在这里插入图片描述

三、通过Pipeline按序运行多个job

pipeline {
    agent any
    stages {
        stage('Trigger Job JenkinsTest1') {
            steps {
                build job: 'JenkinsTest1'
            }
        }
        stage('Trigger Job JenkinsTest2') {
            steps {
                build job: 'JenkinsTest2'
            }
        }
        stage('Trigger Job JenkinsTest3') {
            steps {
                build job: 'JenkinsTest3'
            }
        }
    }
}

运行结果:
在这里插入图片描述

四、通过Pipeline并行运行多个job

pipeline {
    agent any
    stages {
        stage('Trigger Jobs') {
            parallel {
                stage('Job JenkinsTest1') {
                    steps {
                        build job: 'JenkinsTest1'
                    }
                }
                stage('Job Job JenkinsTest2') {
                    steps {
                        build job: 'JenkinsTest2'
                    }
                }
                stage('Job Job JenkinsTest3') {
                    steps {
                        build job: 'JenkinsTest3'
                    }
                }
            }
        }
    }
}

运行结果:
在这里插入图片描述

点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部