Jenkins代码详见:
https://gitee.com/roclli/4-declarative.git
Jenkinsfile内容为:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#!/usr/bing/env groovy
//Declarative
pipeline {
	agent any    		//agent必需的,告诉Jenkins分配执行器和工作空间
    stages {			//stage必需的,
		stage('Build') {
			steps {		//step必需的
				echo 'Building....'
				checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://gitee.com/roclli/4-declarative.git']]])\
//				def username = 'Jenkins'
//				echo 'Hello Mr. ${username}'
//				echo "I said, Hello Mr. ${username}"
			}
		}
		stage('Test') {
			steps{
				echo 'Testing....'
			}
		}
		stage('Deploy') {
			steps{
				echo 'Deploying....'
			}
		}
    }
}