zoukankan      html  css  js  c++  java
  • jenkins之 pipeline 小尝试

    最近,一个小需求,动态建立slave节点来执行自动化用例,原有jenkins 老方式不满足需求,就用到jenkins2的pipeline来实现,但在实现过程中,2个小坑记录下

    1、jenkins不能读取file参数中的文件

     在任务有file参数时,如下:

    然后在pipeline只引用env.env_conf时,发现找不到上传的文件.....<_>

    查看后,原来还是一个bug,见jenkins官网说明,

    代替方案:

     使用multi-line string parameter参数,读取后,再写入到文件

     writeFile file: 'demo.ini', text: env.config

    2、post带node,带脚本

    post属于构建后的操作,官网只是这样显示的

    Jenkinsfile (Declarative Pipeline)
    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'
            }
        }
    }

    NND,这是什么,谁的post会这么简单??

    我要在指定节点运行脚本,发邮件。

    没办法,又是查阅资料后,原来post可以这么写:

    例一:
    
    post {
            success {
                script {
                    currentBuild.result = 'SUCCESS'
                }
                step([$class: 'StashNotifier'])
            }
         }
    例二:带节点生成html,junit
    
    post {
            always {
                node("xxxxx"){
                    publishHTML (target: [
                allowMissing: false,
                alwaysLinkToLastBuild: false,
                keepAll: true,
                reportDir: "${env.Version}/AliApiCrul/.",
                reportFiles: 'index.html',
                reportName: "HTML Report"
                ])
                    junit "${env.Version}/AliApiCrul/*.xml"
                }
  • 相关阅读:
    数组相似性计算
    关于GANs原论文里的数学证明
    Python 画个图
    Golang脱坑指南: goroutine(不断更新)
    Java面试细节整理(不断更新)
    从统计看机器学习(二) 多重共线性的一些思考
    从统计看机器学习(一) 一元线性回归
    数据库存储技术基础(一) 字典编码
    JVM内存管理笔记
    R语言rank函数详细解析
  • 原文地址:https://www.cnblogs.com/landhu/p/8549118.html
Copyright © 2011-2022 走看看