文章目录
一、第一个pipeline
groovy
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程序
groovy
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
groovy
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
groovy
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'
}
}
}
}
}
}
运行结果: