在jenkins可能会有战役中场景,就是在一个job执行完之后,把这个执行结果作为另一个job的执行条件

比如A执行完,如果A执行成功,则执行B,如果失败则执行C

1 前期准备

A任务

import hudson.model.*;
pipeline{
agent any
environment {
INPUT_JSON = "/tmp/test.json"
}
stages{
stage("Hello Pipeline") {
steps {
script {
println "Hello Pipeline!"
println env.JOB_NAME
println env.BUILD_NUMBER
}
}
} stage("Init paramters in json") {
steps {
script { println "read josn input file"
json_file = INPUT_JSON? INPUT_JSON.trim() : ""
prop = readJSON file : json_file
name = prop.NAME? prop.NAME.trim() : ""
println "Name:" + name
age = prop.AGE? prop.AGE.trim() : ""
println "Age:" + age
phone = prop.PHONE_NUMBER? prop.PHONE_NUMBER.trim() : ""
println "Phone:" + phone
address = prop.ADDRESS? prop.ADDRESS.trim() : ""
println "Address:" + address
email = prop.EMAIL? prop.EMAIL.trim() : ""
println "Email:" + email
gender = prop.GENDER? prop.GENDER.trim() : ""
println "Gender:" + gender
is_marry = prop.IS_MARRY? prop.IS_MARRY.trim() : false
println "is_marry:" + is_marry
is_smoke = prop.SMOKE? prop.SMOKE : false
println "is_smoke:" + is_smoke
}
}
}
stage("call a method") {
steps {
script {
println "send the parameter as map type"
model_call = load env.JENKINS_HOME + "/moodlegroovy/model.groovy"
model_call.getUserInfo(name:name, age:age, phone:phone, address:address, email:email, gender:gender, is_marry:is_marry)
}
}
}
stage("check serive up") {
when {
expression {
return is_smoke
}
}
steps {
script {
sh "cat /etc/passwdsd" #修改这里,可以控制此任务是success或者是false
}
}
}
}
}

B 任务

的构建结果

C任务

C的构建结果

2 编写A任务的pipeline

 import hudson.model.*;
pipeline{
agent any
environment {
INPUT_JSON = "/tmp/test.json"
}
stages{
stage("Hello Pipeline") {
steps {
script {
println "Hello Pipeline!"
println env.JOB_NAME
println env.BUILD_NUMBER
}
}
} stage("Init paramters in json") {
steps {
script { println "read josn input file"
json_file = INPUT_JSON? INPUT_JSON.trim() : ""
prop = readJSON file : json_file
name = prop.NAME? prop.NAME.trim() : ""
println "Name:" + name
age = prop.AGE? prop.AGE.trim() : ""
println "Age:" + age
phone = prop.PHONE_NUMBER? prop.PHONE_NUMBER.trim() : ""
println "Phone:" + phone
address = prop.ADDRESS? prop.ADDRESS.trim() : ""
println "Address:" + address
email = prop.EMAIL? prop.EMAIL.trim() : ""
println "Email:" + email
gender = prop.GENDER? prop.GENDER.trim() : ""
println "Gender:" + gender
is_marry = prop.IS_MARRY? prop.IS_MARRY.trim() : false
println "is_marry:" + is_marry
is_smoke = prop.SMOKE? prop.SMOKE : false
println "is_smoke:" + is_smoke
}
}
}
stage("call a method") {
steps {
script {
println "send the parameter as map type"
model_call = load env.JENKINS_HOME + "/moodlegroovy/model.groovy"
model_call.getUserInfo(name:name, age:age, phone:phone, address:address, email:email, gender:gender, is_marry:is_marry)
}
}
}
stage("check serive up") {
when {
expression {
return is_smoke
}
}
steps {
script {
sh "cat /etc/passwd"
}
}
}
}
post {
always {
script {
println "Do some actins when always need."
}
}
failure { #失败执行
script {
println "failure will run JOB B"
jobB = build 'jenkins_pipeline_demo'
println jobB.getResult()
}
}
success { #成功执行
script {
println "Here we kickoff run job C"
jobC = build 'pipelin-jenkinsfile'
println jobC.getResult()
}
}
}
}

3 构建测试

控制台输出

Started by user darren ning
Obtained when.jenkinsfile from git http://192.168.132.132/root/pipeline-parameter-test.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /root/.jenkins/workspace/pipeline_parameter_project
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=
Fetching changes from the remote Git repository
> git config remote.origin.url http://192.168.132.132/root/pipeline-parameter-test.git # timeout=10
Fetching upstream changes from http://192.168.132.132/root/pipeline-parameter-test.git
> git --version # timeout=
> git fetch --tags --progress http://192.168.132.132/root/pipeline-parameter-test.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
Checking out Revision 4a1e49c9e3de8e73ee084ad5c3d707700a9d171b (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=
> git checkout -f 4a1e49c9e3de8e73ee084ad5c3d707700a9d171b
Commit message: "Update when.jenkinsfile"
> git rev-list --no-walk 2e4c72c9ce6c473dd9eaef8805b9df0f5fd8ae44 # timeout=
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Hello Pipeline)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Hello Pipeline!
[Pipeline] echo
pipeline_parameter_project
[Pipeline] echo [Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Init paramters in json)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
read josn input file
[Pipeline] readJSON
[Pipeline] echo
Name:Lucy
[Pipeline] echo
Age:
[Pipeline] echo
Phone:
[Pipeline] echo
Address:Haidian Beijing
[Pipeline] echo
Email:lucy@demo.com
[Pipeline] echo
Gender:male
[Pipeline] echo
is_marry:false
[Pipeline] echo
is_smoke:false
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (call a method)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
send the parameter as map type
[Pipeline] load
[Pipeline] { (/root/.jenkins/moodlegroovy/model.groovy)
[Pipeline] }
[Pipeline] // load
[Pipeline] echo Lucy come from Haidian Beijing, he is old. he's phone number is
, or you can contact he via lucy@demo.com, he is not marry yet. [Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (check serive up)
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ cat /etc/passwd
root:x:::root:/root:/bin/bash
bin:x:::bin:/bin:/sbin/nologin
daemon:x:::daemon:/sbin:/sbin/nologin
adm:x:::adm:/var/adm:/sbin/nologin
lp:x:::lp:/var/spool/lpd:/sbin/nologin
sync:x:::sync:/sbin:/bin/sync
shutdown:x:::shutdown:/sbin:/sbin/shutdown
halt:x:::halt:/sbin:/sbin/halt
mail:x:::mail:/var/spool/mail:/sbin/nologin
operator:x:::operator:/root:/sbin/nologin
games:x:::games:/usr/games:/sbin/nologin
ftp:x:::FTP User:/var/ftp:/sbin/nologin
nobody:x:::Nobody:/:/sbin/nologin
systemd-network:x:::systemd Network Management:/:/sbin/nologin
dbus:x:::System message bus:/:/sbin/nologin
polkitd:x:::User for polkitd:/:/sbin/nologin
postfix:x::::/var/spool/postfix:/sbin/nologin
chrony:x::::/var/lib/chrony:/sbin/nologin
sshd:x:::Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
joy:x:::joy:/home/joy:/bin/bash
tss:x:::Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Do some actins when always need.
[Pipeline] }
[Pipeline] // script
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Here we kickoff run job C
[Pipeline] build (Building pipelin-jenkinsfile)
Scheduling project: pipelin-jenkinsfile
Starting building: pipelin-jenkinsfile #
[Pipeline] }
[Pipeline] // script
Error when executing success post condition:
hudson.AbortException: pipelin-jenkinsfile # completed with status FAILURE (propagate: false to ignore)
at org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerListener.onCompleted(BuildTriggerListener.java:)
at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$(WorkflowRun.java:)
at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$.run(CpsThreadGroup.java:)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$.run(CpsVmExecutorService.java:)
at hudson.remoting.SingleLaneExecutorService$.run(SingleLaneExecutorService.java:)
at jenkins.util.ContextResettingExecutorService$.run(ContextResettingExecutorService.java:)
at jenkins.security.ImpersonatingExecutorService$.run(ImpersonatingExecutorService.java:)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:)
at java.util.concurrent.FutureTask.run(FutureTask.java:)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:)
at java.lang.Thread.run(Thread.java:) [Pipeline] script
[Pipeline] {
[Pipeline] echo
failure will run JOB B
[Pipeline] build (Building jenkins_pipeline_demo)
Scheduling project: jenkins_pipeline_demo
Starting building: jenkins_pipeline_demo #
[Pipeline] }
[Pipeline] // script
Error when executing failure post condition:
hudson.AbortException: jenkins_pipeline_demo # completed with status UNSTABLE (propagate: false to ignore)
at org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerListener.onCompleted(BuildTriggerListener.java:)
at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$(WorkflowRun.java:)
at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$.run(CpsThreadGroup.java:)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$.run(CpsVmExecutorService.java:)
at hudson.remoting.SingleLaneExecutorService$.run(SingleLaneExecutorService.java:)
at jenkins.util.ContextResettingExecutorService$.run(ContextResettingExecutorService.java:)
at jenkins.security.ImpersonatingExecutorService$.run(ImpersonatingExecutorService.java:)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:)
at java.util.concurrent.FutureTask.run(FutureTask.java:)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:)
at java.lang.Thread.run(Thread.java:) [Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: pipelin-jenkinsfile # completed with status FAILURE (propagate: false to ignore)
Finished: FAILURE

执行完A,A成功,触发执行C,C失败,触发又执行B

4 测试A失败,执行

实验A执行失败,修改

 import hudson.model.*;
pipeline{
agent any
environment {
INPUT_JSON = "/tmp/test.json"
}
stages{
stage("Hello Pipeline") {
steps {
script {
println "Hello Pipeline!"
println env.JOB_NAME
println env.BUILD_NUMBER
}
}
} stage("Init paramters in json") {
steps {
script { println "read josn input file"
json_file = INPUT_JSON? INPUT_JSON.trim() : ""
prop = readJSON file : json_file
name = prop.NAME? prop.NAME.trim() : ""
println "Name:" + name
age = prop.AGE? prop.AGE.trim() : ""
println "Age:" + age
phone = prop.PHONE_NUMBER? prop.PHONE_NUMBER.trim() : ""
println "Phone:" + phone
address = prop.ADDRESS? prop.ADDRESS.trim() : ""
println "Address:" + address
email = prop.EMAIL? prop.EMAIL.trim() : ""
println "Email:" + email
gender = prop.GENDER? prop.GENDER.trim() : ""
println "Gender:" + gender
is_marry = prop.IS_MARRY? prop.IS_MARRY.trim() : false
println "is_marry:" + is_marry
is_smoke = prop.SMOKE? prop.SMOKE : false
println "is_smoke:" + is_smoke
}
}
}
stage("call a method") {
steps {
script {
println "send the parameter as map type"
model_call = load env.JENKINS_HOME + "/moodlegroovy/model.groovy"
model_call.getUserInfo(name:name, age:age, phone:phone, address:address, email:email, gender:gender, is_marry:is_marry)
}
}
}
stage("check serive up") {
when {
expression {
return is_smoke
}
}
steps {
script {
sh "cat /etc/passwdsd"
}
}
}
}
post {
always {
script {
println "Do some actins when always need."
}
}
failure {
script {
println "failure will run JOB B"
jobB = build 'jenkins_pipeline_demo'
println jobB.getResult()
}
}
success {
script {
println "Here we kickoff run job C"
jobC = build 'pipelin-jenkinsfile'
println jobC.getResult()
}
}
}
}

构建输出

Started by user darren ning
Obtained when.jenkinsfile from git http://192.168.132.132/root/pipeline-parameter-test.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /root/.jenkins/workspace/pipeline_parameter_project
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=
Fetching changes from the remote Git repository
> git config remote.origin.url http://192.168.132.132/root/pipeline-parameter-test.git # timeout=10
Fetching upstream changes from http://192.168.132.132/root/pipeline-parameter-test.git
> git --version # timeout=
> git fetch --tags --progress http://192.168.132.132/root/pipeline-parameter-test.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
Checking out Revision 227a5d7072890746c966827fda49a168f8999679 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=
> git checkout -f 227a5d7072890746c966827fda49a168f8999679
Commit message: "Update when.jenkinsfile"
> git rev-list --no-walk 4a1e49c9e3de8e73ee084ad5c3d707700a9d171b # timeout=
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Hello Pipeline)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Hello Pipeline!
[Pipeline] echo
pipeline_parameter_project
[Pipeline] echo [Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Init paramters in json)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
read josn input file
[Pipeline] readJSON
[Pipeline] echo
Name:Lucy
[Pipeline] echo
Age:
[Pipeline] echo
Phone:
[Pipeline] echo
Address:Haidian Beijing
[Pipeline] echo
Email:lucy@demo.com
[Pipeline] echo
Gender:male
[Pipeline] echo
is_marry:false
[Pipeline] echo
is_smoke:false
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (call a method)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
send the parameter as map type
[Pipeline] load
[Pipeline] { (/root/.jenkins/moodlegroovy/model.groovy)
[Pipeline] }
[Pipeline] // load
[Pipeline] echo Lucy come from Haidian Beijing, he is old. he's phone number is
, or you can contact he via lucy@demo.com, he is not marry yet. [Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (check serive up)
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ cat /etc/passwdsd
cat: /etc/passwdsd: No such file or directory
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Do some actins when always need.
[Pipeline] }
[Pipeline] // script
[Pipeline] script
[Pipeline] {
[Pipeline] echo
failure will run JOB B
[Pipeline] build (Building jenkins_pipeline_demo)
Scheduling project: jenkins_pipeline_demo
Starting building: jenkins_pipeline_demo #
[Pipeline] echo
SUCCESS
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code
Finished: FAILURE

5 测试都可以成功的job

更换C为一个能执行成功的job

修改jenkinsfile

 import hudson.model.*;
pipeline{
agent any
environment {
INPUT_JSON = "/tmp/test.json"
}
stages{
stage("Hello Pipeline") {
steps {
script {
println "Hello Pipeline!"
println env.JOB_NAME
println env.BUILD_NUMBER
}
}
} stage("Init paramters in json") {
steps {
script { println "read josn input file"
json_file = INPUT_JSON? INPUT_JSON.trim() : ""
prop = readJSON file : json_file
name = prop.NAME? prop.NAME.trim() : ""
println "Name:" + name
age = prop.AGE? prop.AGE.trim() : ""
println "Age:" + age
phone = prop.PHONE_NUMBER? prop.PHONE_NUMBER.trim() : ""
println "Phone:" + phone
address = prop.ADDRESS? prop.ADDRESS.trim() : ""
println "Address:" + address
email = prop.EMAIL? prop.EMAIL.trim() : ""
println "Email:" + email
gender = prop.GENDER? prop.GENDER.trim() : ""
println "Gender:" + gender
is_marry = prop.IS_MARRY? prop.IS_MARRY.trim() : false
println "is_marry:" + is_marry
is_smoke = prop.SMOKE? prop.SMOKE : false
println "is_smoke:" + is_smoke
}
}
}
stage("call a method") {
steps {
script {
println "send the parameter as map type"
model_call = load env.JENKINS_HOME + "/moodlegroovy/model.groovy"
model_call.getUserInfo(name:name, age:age, phone:phone, address:address, email:email, gender:gender, is_marry:is_marry)
}
}
}
stage("check serive up") {
when {
expression {
return is_smoke
}
}
steps {
script {
sh "cat /etc/passwd"
}
}
}
}
post {
always {
script {
println "Do some actins when always need."
}
}
failure {
script {
println "failure will run JOB B"
jobB = build 'jenkins_pipeline_demo'
println jobB.getResult()
}
}
success {
script {
println "Here we kickoff run job C"
jobC = build 'jenkins_pineline_demo_utility'
println jobC.getResult()
}
}
}
}

执行全部成功

控制台输出

Started by user darren ning
Obtained when.jenkinsfile from git http://192.168.132.132/root/pipeline-parameter-test.git
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /root/.jenkins/workspace/pipeline_parameter_project
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
No credentials specified
> git rev-parse --is-inside-work-tree # timeout=
Fetching changes from the remote Git repository
> git config remote.origin.url http://192.168.132.132/root/pipeline-parameter-test.git # timeout=10
Fetching upstream changes from http://192.168.132.132/root/pipeline-parameter-test.git
> git --version # timeout=
> git fetch --tags --progress http://192.168.132.132/root/pipeline-parameter-test.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=
Checking out Revision 632df80c513982664b30606fc6e38778e1bbc54d (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=
> git checkout -f 632df80c513982664b30606fc6e38778e1bbc54d
Commit message: "Update when.jenkinsfile"
> git rev-list --no-walk 227a5d7072890746c966827fda49a168f8999679 # timeout=
[Pipeline] }
[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Hello Pipeline)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Hello Pipeline!
[Pipeline] echo
pipeline_parameter_project
[Pipeline] echo [Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Init paramters in json)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
read josn input file
[Pipeline] readJSON
[Pipeline] echo
Name:Lucy
[Pipeline] echo
Age:
[Pipeline] echo
Phone:
[Pipeline] echo
Address:Haidian Beijing
[Pipeline] echo
Email:lucy@demo.com
[Pipeline] echo
Gender:male
[Pipeline] echo
is_marry:false
[Pipeline] echo
is_smoke:false
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (call a method)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
send the parameter as map type
[Pipeline] load
[Pipeline] { (/root/.jenkins/moodlegroovy/model.groovy)
[Pipeline] }
[Pipeline] // load
[Pipeline] echo Lucy come from Haidian Beijing, he is old. he's phone number is
, or you can contact he via lucy@demo.com, he is not marry yet. [Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (check serive up)
[Pipeline] script
[Pipeline] {
[Pipeline] sh
+ cat /etc/passwd
root:x:::root:/root:/bin/bash
bin:x:::bin:/bin:/sbin/nologin
daemon:x:::daemon:/sbin:/sbin/nologin
adm:x:::adm:/var/adm:/sbin/nologin
lp:x:::lp:/var/spool/lpd:/sbin/nologin
sync:x:::sync:/sbin:/bin/sync
shutdown:x:::shutdown:/sbin:/sbin/shutdown
halt:x:::halt:/sbin:/sbin/halt
mail:x:::mail:/var/spool/mail:/sbin/nologin
operator:x:::operator:/root:/sbin/nologin
games:x:::games:/usr/games:/sbin/nologin
ftp:x:::FTP User:/var/ftp:/sbin/nologin
nobody:x:::Nobody:/:/sbin/nologin
systemd-network:x:::systemd Network Management:/:/sbin/nologin
dbus:x:::System message bus:/:/sbin/nologin
polkitd:x:::User for polkitd:/:/sbin/nologin
postfix:x::::/var/spool/postfix:/sbin/nologin
chrony:x::::/var/lib/chrony:/sbin/nologin
sshd:x:::Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
joy:x:::joy:/home/joy:/bin/bash
tss:x:::Account used by the trousers package to sandbox the tcsd daemon:/dev/null:/sbin/nologin
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Do some actins when always need.
[Pipeline] }
[Pipeline] // script
[Pipeline] script
[Pipeline] {
[Pipeline] echo
Here we kickoff run job C
[Pipeline] build (Building jenkins_pineline_demo_utility)
Scheduling project: jenkins_pineline_demo_utility
Starting building: jenkins_pineline_demo_utility #
[Pipeline] echo
SUCCESS
[Pipeline] }
[Pipeline] // script
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

测试完成

DEVOPS技术实践_20:串联多个job执行的更多相关文章

  1. DEVOPS技术实践_06:sonar与Jenksin集成

    代码质量管理平台 一.checkout和打包功能 1.1 gitlab在新建一个文件 后续在写入内容 1.2 Jenkins新建一个任务 两个参数 1.3 流水线配置 copy仓库地址: http:/ ...

  2. DEVOPS技术实践_04:Jenkins参数化构建

    一.参数化构建 1.1 各个参数的信息 凭据参数存储一个用户的账号密码信息,等等,运用最多的是选项参数 1.2 使用选项参数 构建已经变成参数化构建 1.3 获取这个值,修改Jenkinsfile文件 ...

  3. DEVOPS技术实践_03:Jenkins自动构建

    一.提交代码自动构建 当开发人员在gitlab提交代码后,会自动触发jenkin构建 点击项目---->点击diy_maven-TEST----->点击配置--->构建触发器---- ...

  4. DEVOPS技术实践_23:判断文件下载成功作为执行条件

    在实际生产中,我们经常会需要通过判断一个结果作为一个条件去执行另一个内容,比如判断一个文件是否存在,判官一个命令是否执行成功等等 现在我们选择其中一个场景进行实验,当某个目录下存在,则执行操作 1. ...

  5. DEVOPS技术实践_22:根据参数传入条件控制执行不同stage

    前面学习了参数的传递和调用,下面研究一下根据参数作为条件执行不同的stage 使用叫when 和expression控制某一个stage的运行, 运行场景例如写了多个stage,这个pipeline脚 ...

  6. DEVOPS技术实践_21:Pipeline的嵌套以及流程控制的if和case语句

    1 if控制语句 使用一个简单的If控制语句 pipeline { agent any stages { stage('flow control') { steps { script { == ) { ...

  7. DEVOPS技术实践_19:Pipeline的多参数json调用

    在上一篇学习了把参数写进Json文件,然后通过去Json文件,调用参数的方法 1. 三元运算符介绍 调用的方法是通过一个三元运算符实现的 gender = prop.GENDER? prop.GEND ...

  8. DEVOPS技术实践_18:Jenkins的Pinpeline对于参数的使用

    因为最近使用Pipeline声明式语法构建项目,但是最近项目的参数设置较多,特地的来学习一下关于参数的调用和测试,主要式从一个大神那里学习的,结尾回贴上大神的博客链接 1 构建一个pipeline项目 ...

  9. DEVOPS技术实践_17:Jenkins使用扩展邮件功能发送邮件

    一 环境准备 1.1 安装插件Email Extension 系统管理-管理插件-安装Email Extension插件 1.2 配置 配置jenkins邮箱的全局配置:系统管理-系统设置-完成邮箱配 ...

随机推荐

  1. 什么是Hessian协议呢?

    什么是Hessian协议呢? 目前,Web服务技术是解决异构平台系统的集成及互操作问题的主流技术. 它所基于的XML已经是Internet上交换数据的实际标准,基于通用的进程间通信协议和网络传输协议屏 ...

  2. Java练习 SDUT-2761_编码

    编码 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 给你一个由大写字母组成的组成的字符串,你可以用如下规则对其进行编码 ...

  3. Dataphin公共云重磅发布,提供一站式智能数据构建与管理能

    点击订阅新品发布会! 新产品.新版本.新技术.新功能.价格调整,评论在下方,下期更新!关注更多内容,了解更多 最新发布 Dataphin公共云重磅发布 2019年6月26日15时,阿里云Dataphi ...

  4. js获取当前日期及获取当前日期的前一天日期函数

    function getcurrentdate(){ //获取系统时间var LSTR_ndate=new Date();var LSTR_Year=LSTR_ndate.getFullYear(); ...

  5. tinyhttpd简介

    一:简介: tinyhttpd是由J. DavidBlackstone在1999年编写的,实现了一个很简单的web服务器.支持GET和POST方法,总代码量也就在500行左右,可以用来学习HTTP协议 ...

  6. eBPF Tracing 入门教程与实例

    原文链接 Learn eBPF Tracing: Tutorial and Examples译者 弃余 在 LPC'18(Linux Plumber's conference) 会议上,至少有24个关 ...

  7. linux 一些简单操作

    vim   ----三种模式 1.命令模式           2.输出模式       3.底线命令模式 w(e) 移动光标到下一个单词 b 移动到光标上一个单词 数字0 移动到本行开头 $ 移动光 ...

  8. jsp中文乱码六种情况---解决方案

    转 jsp中文乱码六种情况---解决方案 2016年10月22日 21:32:55 阅读数:10672 来源:http://blog.csdn.net/lovesummerforever/articl ...

  9. 2019-7-29-NetBIOS-计算机名称命名限制

    title author date CreateTime categories NetBIOS 计算机名称命名限制 lindexi 2019-07-29 09:59:17 +0800 2018-12- ...

  10. 如何利用aop的环绕消息处理log, 以及各种坑的记录

    如何利用aop的环绕消息处理log, 以及各种坑的记录 本文链接: https://www.cnblogs.com/zizaiwuyou/p/11667423.html 因为项目里有很多地方要打log ...