zoukankan      html  css  js  c++  java
  • DEVOPS技术实践_20:串联多个job执行

    在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=10
    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=10
     > 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=10
     > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
    Checking out Revision 4a1e49c9e3de8e73ee084ad5c3d707700a9d171b (refs/remotes/origin/master)
     > git config core.sparsecheckout # timeout=10
     > git checkout -f 4a1e49c9e3de8e73ee084ad5c3d707700a9d171b
    Commit message: "Update when.jenkinsfile"
     > git rev-list --no-walk 2e4c72c9ce6c473dd9eaef8805b9df0f5fd8ae44 # timeout=10
    [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
    77
    [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:18
    [Pipeline] echo
    Phone:13912345678
    [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 18 old. he's phone number is
        13912345678, 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:0:0:root:/root:/bin/bash
    bin:x:1:1:bin:/bin:/sbin/nologin
    daemon:x:2:2:daemon:/sbin:/sbin/nologin
    adm:x:3:4:adm:/var/adm:/sbin/nologin
    lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
    sync:x:5:0:sync:/sbin:/bin/sync
    shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
    halt:x:7:0:halt:/sbin:/sbin/halt
    mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
    operator:x:11:0:operator:/root:/sbin/nologin
    games:x:12:100:games:/usr/games:/sbin/nologin
    ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
    nobody:x:99:99:Nobody:/:/sbin/nologin
    systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
    dbus:x:81:81:System message bus:/:/sbin/nologin
    polkitd:x:999:997:User for polkitd:/:/sbin/nologin
    postfix:x:89:89::/var/spool/postfix:/sbin/nologin
    chrony:x:998:996::/var/lib/chrony:/sbin/nologin
    sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
    joy:x:1000:1000:joy:/home/joy:/bin/bash
    tss:x:59:59: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 #12
    [Pipeline] }
    [Pipeline] // script
    Error when executing success post condition:
    hudson.AbortException: pipelin-jenkinsfile #12 completed with status FAILURE (propagate: false to ignore)
        at org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerListener.onCompleted(BuildTriggerListener.java:52)
        at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:209)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:584)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$1000(WorkflowRun.java:133)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:996)
        at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1463)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:458)
        at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:37)
        at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    
    [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 #8
    [Pipeline] }
    [Pipeline] // script
    Error when executing failure post condition:
    hudson.AbortException: jenkins_pipeline_demo #8 completed with status UNSTABLE (propagate: false to ignore)
        at org.jenkinsci.plugins.workflow.support.steps.build.BuildTriggerListener.onCompleted(BuildTriggerListener.java:52)
        at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:209)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:584)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$1000(WorkflowRun.java:133)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:996)
        at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1463)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:458)
        at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:37)
        at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
        at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] }
    [Pipeline] // withEnv
    [Pipeline] }
    [Pipeline] // withEnv
    [Pipeline] }
    [Pipeline] // node
    [Pipeline] End of Pipeline
    ERROR: pipelin-jenkinsfile #12 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=10
    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=10
     > 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=10
     > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
    Checking out Revision 227a5d7072890746c966827fda49a168f8999679 (refs/remotes/origin/master)
     > git config core.sparsecheckout # timeout=10
     > git checkout -f 227a5d7072890746c966827fda49a168f8999679
    Commit message: "Update when.jenkinsfile"
     > git rev-list --no-walk 4a1e49c9e3de8e73ee084ad5c3d707700a9d171b # timeout=10
    [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
    78
    [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:18
    [Pipeline] echo
    Phone:13912345678
    [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 18 old. he's phone number is
        13912345678, 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 #9
    [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 1
    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=10
    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=10
     > 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=10
     > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
    Checking out Revision 632df80c513982664b30606fc6e38778e1bbc54d (refs/remotes/origin/master)
     > git config core.sparsecheckout # timeout=10
     > git checkout -f 632df80c513982664b30606fc6e38778e1bbc54d
    Commit message: "Update when.jenkinsfile"
     > git rev-list --no-walk 227a5d7072890746c966827fda49a168f8999679 # timeout=10
    [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
    79
    [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:18
    [Pipeline] echo
    Phone:13912345678
    [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 18 old. he's phone number is
        13912345678, 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:0:0:root:/root:/bin/bash
    bin:x:1:1:bin:/bin:/sbin/nologin
    daemon:x:2:2:daemon:/sbin:/sbin/nologin
    adm:x:3:4:adm:/var/adm:/sbin/nologin
    lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
    sync:x:5:0:sync:/sbin:/bin/sync
    shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
    halt:x:7:0:halt:/sbin:/sbin/halt
    mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
    operator:x:11:0:operator:/root:/sbin/nologin
    games:x:12:100:games:/usr/games:/sbin/nologin
    ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
    nobody:x:99:99:Nobody:/:/sbin/nologin
    systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
    dbus:x:81:81:System message bus:/:/sbin/nologin
    polkitd:x:999:997:User for polkitd:/:/sbin/nologin
    postfix:x:89:89::/var/spool/postfix:/sbin/nologin
    chrony:x:998:996::/var/lib/chrony:/sbin/nologin
    sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
    joy:x:1000:1000:joy:/home/joy:/bin/bash
    tss:x:59:59: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 #37
    [Pipeline] echo
    SUCCESS
    [Pipeline] }
    [Pipeline] // script
    [Pipeline] }
    [Pipeline] // stage
    [Pipeline] }
    [Pipeline] // withEnv
    [Pipeline] }
    [Pipeline] // withEnv
    [Pipeline] }
    [Pipeline] // node
    [Pipeline] End of Pipeline
    Finished: SUCCESS

    测试完成

  • 相关阅读:
    poj3669 广搜
    检索所有课程都选修的的学生的学号与姓名
    UVA10160 Servicing Stations
    uva11205 The broken pedometer 子集生成
    poj1101 the game 广搜
    poj3009 Curling 2.0 深搜
    poj 1564 Sum It Up 搜索
    HDU 2268 How To Use The Car (数学题)
    codeforces 467C George and Job(简单dp,看了题解抄一遍)
    HDU 2267 How Many People Can Survive(广搜,简单)
  • 原文地址:https://www.cnblogs.com/zyxnhr/p/11886305.html
Copyright © 2011-2022 走看看