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;'
        }
    }
    
    本人水平有限,还在不断学习中 难免有很多错误或者遗漏,望见谅
  • 相关阅读:
    Spring MVC 教程(比较全的一篇文章了)
    关于F12的有效利用
    论运营工作与小区收垃圾的相似之处
    吴淞炮台湾湿地森林公园半日游
    真正的运营
    今天是入职通联3周年
    甲午年过临海
    购买vps创建账号后无法登录ftp
    prim+BFS
    最小生成树
  • 原文地址:https://www.cnblogs.com/faberbeta/p/14696138.html
Copyright © 2011-2022 走看看