zoukankan      html  css  js  c++  java
  • jenkins pipeline 常用句式

    Jenkinsfile
    邮件报警需要安装emailext插件,这个插件可以把jenkins发布的日志加到邮件中,以及使用模板
    脚本式 jenkins pipeline 发送邮件

    //=================自定义信息===============
    //harbor 仓库名称, 例如mobile,computer,testmonitor等等
    def harbor_project = "mobile"
    //docker构建版本tag
    def tag = "latest"
    //git 地址
    def git_addr= "git@github.com:api/mobile-go.git"
    //=================定义公用信息===============
    //harbor地址
    def harborUrl = "harbor.test.com"
    //harbor测试
    def harborAuth = "495d3b1a-a616-44d3-ae91-4b6e004076bd"
    //gitlab的凭证
    def git_auth = "330de1e8-1525-45e5-971e-da440ad5b810"
    //获取当前选择的项目名称
    def selectedProjects = "${project_name}".split(',')
    
    node {
        try {
    
    
           stage('拉取代码') { // for display purposes
              // Get some code from a GitHub repository
             checkout([$class: 'GitSCM', branches: [[name: "${git_version}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_addr}"]]])
              // Get the Maven tool.
              // ** NOTE: This 'M3' Maven tool must be configured
              // **       in the global configuration.
           }
    
            stage('代码编译') {
                for(int i=0;i<selectedProjects.size();i++){
                    //取出每个项目的名称
                    def currentProjectName = selectedProjects[i];
                        echo "${currentProjectName}"
                        echo "做点什么,已省略。。。"
                }
            }
            currentBuild.result = 'SUCCESS'
        }
    
        catch(e) {
            currentBuild.result = 'FAILURE'
        }
    
        finally {
            emailext attachLog: true, body: '$DEFAULT_CONTENT', subject: "[JENKINS]V3 ${selectedProjects}发布${currentBuild.result}", to: 'xxx@test.com;'
        }
    }
    
    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    SSD报告
    House of Spirit学习调试验证与实践
    怎样改动SharePoint管理中心的语言
    PuTTY连接Linuxserver常常断线解决方式
    HDU 2819 Swap (行列匹配+输出解)
    HDOJ--1061--Rightmost Digit
    POJ Cow Exhibition
    程序员之---C语言细节24(段错误、类型提升、sizeof &#39;A&#39;)
    java之 ------ 图形界面(三)
    Oracle 安装报错 [INS-06101] IP address of localhost could not be determined 解决方法
  • 原文地址:https://www.cnblogs.com/faberbeta/p/14696138.html
Copyright © 2011-2022 走看看