zoukankan      html  css  js  c++  java
  • jenkins 获取当前上传的分支的commit + url跳转

    pipeline{
        agent any 
        environment {
            def git_url = "###"
            def appdir= "###"
            def localAppRoot = "###"
            def stagingip="###"
            def furl="###"
        }
        stages{
            stage('clear dir'){
                steps{
                    echo "clear dir"
                    sh  '''
                        #!/bin/bash -xe
                        rm -rf ./*
                        '''
                }
            }
            stage('pull code and config'){
                steps{
                    echo "checkout from git"
                    sh "git clone ${git_url}"
                }
            }
            stage('compile and package'){
                steps{
                    echo "compile and package"
                    sh '''
                        cd ${localAppRoot}
                        mvn clean package -DskipTests
                    '''
                    #获取当前代码的最新commit id, 并且url 跳转当前commit id对应的代码仓库
                    script{
                        result = sh(script: "cd ${localAppRoot} && git rev-parse HEAD", returnStdout: true).trim()
                        currentBuild.displayName="#${BUILD_ID}-${result}"
                        currentBuild.description="<a href=http://${furl}${result}>jump</a>"
                    }
                }
            }
            stage('deploy production'){
                when{
                    environment name: 'DEPLOY_TO', value: 'prod'
                }
                steps{
                    sh '''
                        sh /opt/scripts/###.sh ${sub_app_name}  ${appdir} ### ${WORKSPACE}/${localAppRoot} ###
                    '''
                }
            }
            stage('deploy pre-release'){
                when{
                    environment name: 'DEPLOY_TO', value: 'staging'
                }
                steps{
                    sh '''
                        echo "hello"
                        sh /opt/scripts/###.sh ${sub_app_name} ${appdir}  ### ${WORKSPACE}/${localAppRoot} ### $stagingip
                    '''
                }
            }
        }
    }

    如图:

  • 相关阅读:
    .gitignore 文件没起作用
    HTML 中img标签不显示
    关于拖拽
    关于javascript三目
    封装ajax
    javascript-时间戳
    关于Vue实例的生命周期created和mounted的区别
    ES6核心内容讲解
    jsonp跨域请求
    javascript-AJAX
  • 原文地址:https://www.cnblogs.com/bill2014/p/15129603.html
Copyright © 2011-2022 走看看