• pipline --学习 (-)


    一,语法:

      编写位置:    

      pipline 启动docker

    pipeline {
        agent { docker 'maven:3.3.3' }
        stages {
            stage('build') {
                steps {
                    sh 'mvn --version'
                }
            }
        }
    }

      执行shell

    pipeline {
        agent any
        stages {
            stage('Build') {
                steps {
                    sh 'echo "Hello World"'
                    sh '''
                        echo "Multiline shell steps works too"
                        ls -lah
                    '''
                }
            }
        }
    }

      超时配置

      “包装”其他步骤,可以轻松地解决问题,如重试(retry)步骤,直到成功或退出,如果步骤太长(timeout

    pipeline {
        agent any
        stages {
            stage('Deploy') {
                steps {
                    retry(3) {
                        sh './flakey-deploy.sh'
                    }
    
                    timeout(time: 3, unit: 'MINUTES') {
                        sh './health-check.sh'
                    }
                }
            }
        }
    }

      对应执行结果执行不同内容

      

    pipeline {
        agent any
        stages {
            stage('Test') {
                steps {
                    sh 'echo "Fail!"; exit 1'
                }
            }
        }
        post {
            always {
                echo 'This will always run'
            }
            success {
                echo 'This will run only if successful'
            }
            failure {
                echo 'This will run only if failed'
            }
            unstable {
                echo 'This will run only if the run was marked as unstable'
            }
            changed {
                echo 'This will run only if the state of the Pipeline has changed'
                echo 'For example, if the Pipeline was previously failing but is now successful'
            }
        }
    }

      dock er 内执行命令  

    node {
        /* Requires the Docker Pipeline plugin to be installed */
        docker.image('node:7-alpine').inside {
            stage('Test') {
                sh 'node --version'
            }
        }
    }

      基本流程

      

    pipeline {
        agent any
        stages {
            stage('Build') {
                steps {
                    echo 'Building'
                }
            }
            stage('Test') {
                steps {
                    echo 'Testing'
                }
            }
            stage('Deploy') {
                steps {
                    echo 'Deploying'
                }
            }
        }
    }

        

      

    出处

     https://www.w3cschool.cn/jenkins/jenkins-jg9528pb.html

      

  • 相关阅读:
    041_form表单重置数据reset()
    040_下拉列表的显示与提交数值时,需要用到转义字符
    039_如何选取checkbox的id值?
    011_表单数据非空验证
    010_@ResposBody错误
    010_页面单击按钮失灵
    使用Maven创建 web项目
    java设计模式(八) 适配器模式
    设计模式 6大设计原则
    Java设计模式(七) 模板模式-使用钩子
  • 原文地址:https://www.cnblogs.com/kingle-study/p/10268099.html
Copyright © 2020-2023  润新知