1 | node { |
测试人员的技术博客;交流请加QQ群:549576208
1 | node { |
Jenkins代码详见:
https://gitee.com/roclli/9-multipleagent.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48pipeline {
agent none
stages {
stage('Build') {
agent any
steps {
checkout scm
echo '---going to execute---'
sh 'mvn -DskipTests clean package'
stash includes: '**/target/*.jar', name: 'app'
}
}
stage('Test on Linux') {
agent {
label 'linux'
}
steps {
unstash 'app'
sh 'mvn test -Dtest=*Test || true'
}
post {
always {
junit '**/target/surefire-reports/TEST-**.xml'
}
failure {
echo '---on linux, there is some error---'
}
}
}
stage('Test on Windows') {
agent {
label 'windows'
}
steps {
unstash 'app'
bat 'mvn test -Dtest=*Test'
}
post {
always {
junit '**/target/surefire-reports/TEST-**.xml'
}
failure {
echo '---on windows, there is some error---'
}
}
}
}
}
1 | node { |
Jenkins代码详见:
https://gitee.com/roclli/7-parameters-script.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
27pipeline {
agent any
stages {
stage('Test') {
steps {
checkout scm //此处实际上执行了两次,第一次是界面指定了scm,本次又执行了一次
echo '---going to execute---'
sh 'mvn verify'
}
}
}
post {
always {
echo '---going to catch report---'
junit '**/target/surefire-reports/TEST-**.xml'
}
failure {
echo '---send mail start---'
// mail to: 'lijun11@metersbonwe.com', subject: 'The Pipeline(handing failure) failed :(', body: 'this is body'
// mail to: 'devops@acme.com', subject: "Job '${JOB_NAME}' (${BUILD_NUMBER}) is waiting for input",
// body: "Please go to ${BUILD_URL} and verify the build"
// step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "lijun11@metersbonwe.com", sendToIndividuals: true])
emailext body: 'this is body', subject: 'The Pipeline(handing failure) failed :(', to: 'lijun11@metersbonwe.com'
echo '---send mail done---'
}
}
}
1 | properties([parameters([string(defaultValue: 'Hello', description: 'How should I greet the world?', name: 'Greeting')])]) |
Jenkins代码详见:
https://gitee.com/roclli/7-parameters-script.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
27pipeline {
agent any
stages {
stage('Test') {
steps {
checkout scm //此处实际上执行了两次,第一次是界面指定了scm,本次又执行了一次
echo '---going to execute---'
sh 'mvn verify'
}
}
}
post {
always {
echo '---going to catch report---'
junit '**/target/surefire-reports/TEST-**.xml'
}
failure {
echo '---send mail start---'
// mail to: 'lijun11@metersbonwe.com', subject: 'The Pipeline(handing failure) failed :(', body: 'this is body'
// mail to: 'devops@acme.com', subject: "Job '${JOB_NAME}' (${BUILD_NUMBER}) is waiting for input",
// body: "Please go to ${BUILD_URL} and verify the build"
// step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "lijun11@metersbonwe.com", sendToIndividuals: true])
emailext body: 'this is body', subject: 'The Pipeline(handing failure) failed :(', to: 'lijun11@metersbonwe.com'
echo '---send mail done---'
}
}
}
1 | node { |
Jenkins代码详见:
https://gitee.com/roclli/6-setting-env.git
Jenkinsfile内容为:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#!/usr/bing/env groovy
pipeline {
agent any
environment {
CC = 'clang'
}
stages {
stage('Example'){
environment {
DEBUG = '-g'
}
steps{
sh 'printenv'
}
}
}
}
1 | node { |
Jenkins代码详见:
https://gitee.com/roclli/5-build-tests.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47#!/usr/bing/env groovy
pipeline {
agent any //agent必需的,告诉Jenkins分配执行器和工作空间
stages { //stage必需的,
stage('Build') {
steps { //step必需的
echo 'going to git clone......'
git url: 'https://gitee.com/roclli/5-build-tests.git'
echo "going to build.........."
sh "mvn -B -Dmaven.test.failure.ignore verify"
echo "going to archiveArtifacts jar.........."
archiveArtifacts artifacts: '**/target/**.jar', fingerprint: true
}
}
stage('Test'){
steps{
// sh '/mvn_home/bin/mvn clean install || true'
// sh "/mvn_home/bin/mvn -B -Dmaven.test.failure.ignore verify"
echo "junit testreport.........."
junit '**/target/surefire-reports/TEST-**.xml'
}
}
stage('Deploy'){
steps {
script{
echo "---${env.BUILD_NUMBER}---"
echo "---${currentBuild.result}---"
echo "---env.BUILD_ID is:${env.BUILD_ID}---"
echo "---env.JOB_NAME is:${env.JOB_NAME}---"
echo "---env.JENKINS_URL is:${env.JENKINS_URL}---"
if(currentBuild.result == null || currentBuild.result == "SUCCESS") {
echo "---currentBuild.result is:${currentBuild.result}------"
}
else {
echo "---currentBuild.result is:${currentBuild.result},so, will make publish"
}
}
}
}
}
}
tag:
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent: meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true