• 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"
                }
  • 相关阅读:
    【404】int main(int argc,char * argv[]) windows 下的使用
    【403】COMP9024 Exercise
    【402】Twitter Data Collection
    【401】Python 求合数的所有质数因子
    【400】numpy.pad 为数组加垫(迷宫类题目)
    iOS开发之指纹解锁
    iOS-响应链(Responder Chain)
    iOS上手指点击波纹效果的实现
    使用methodSignatureForSelector与forwardInvocation实现消息转发 (转)
    Objective-C中的@dynamic(转)
  • 原文地址:https://www.cnblogs.com/landhu/p/8549118.html
Copyright © 2020-2023  润新知