导语:jenkins 流水线git下载10分钟超时,算法代码太大了。下载大概要30分钟,默认超时时10分钟

在普通风格的job里可以有如下配置

在steps后加入以下内容 替换原先git相关内容

 steps {
                checkout([$class: 'GitSCM', branches: [[name: '${params.branchTag}']], extensions: [[$class: 'CloneOption', noTags: false, reference: '', shallow: false, timeout: 30]], userRemoteConfigs: [[credentialsId: '81f18226-d36e-4a0e-bd0e-b936843ae77b', url: 'http://xxxxx.git']]])

.....



}

下载代码时超时为30分钟了

贴一下流水线

#!groovy

pipeline {
    options {
        timestamps()
        //保持构建的最大个数
        buildDiscarder(logRotator(numToKeepStr: '10'))
        timeout(unit: 'SECONDS', time: 3600)
    }
    agent {
        label "172.16.40.245"
    }


    //定义构建参数
    parameters {
        // string(name: 'Branch', defaultValue: 'master',description: '分支名称')
        // string(name: 'RELEASE_VERSION', defaultValue: "", description: 'Message: 请选择部署的Tags版本?')
        // gitParameter branchFilter: '(.*)', defaultValue: 'V2021430', description: 'Message: 请选择部署的版本', name: 'RELEASE_VERSION', type: 'PT_TAG',listSize: "12"
        gitParameter branchFilter: 'origin/(.*)', defaultValue: '20220531_sp2', description: 'Message: 请选择部署的版本', name: 'RELEASE_VERSION', type: 'PT_BRANCH',listSize: "12"
        imageTag(name: 'DOCKER_IMAGE', description: '',
             image: 'fe/', filter: '', defaultTag: 'ge930',
             registry: 'http://10.10.3.246', credentialId: '18060a85-ebcf-4aa4-bca7-b267c07497f3', tagOrder: 'NATURAL') 
    }

    environment {
        // 项目名称
        Unzip_Path="/data1/TestPackage/lung/cta/"

        // 项目名称
        // Migration_Path="/data1/TestPackage/platform_migration"
//        unzip_files="aiserver-config-migration-*-SNAPSHOT"
//        jenkins_zip="aiserver-config-migration*.zip"
        Tag = "`date '+%Y-%m-%d-%H'-${BUILD_NUMBER}`"
        // 工程名称
        // Date=`date +'%Y-%m-%d_%H:%M:%S'`

    }





    //执行任务模块
    stages {

        //拉取安装包
        stage('下代码') {
            agent {
                label "master"
            }
            steps {
                // checkout([$class: 'GitSCM', branches: [[name: '${params.RELEASE_VERSION}']], extensions: [[$class: 'CloneOption', noTags: false, reference: '', shallow: false, timeout: 30]], userRemoteConfigs: [[credentialsId: '81f18226-d36e-4a0e-bd0e-b936843ae77b', url: '${url}']]])
                // checkout([$class: 'GitSCM', branches: [[name: "${params.branchTag}"]], doGenerateSubmoduleConfigurations: false, userRemoteConfigs: [[credentialsId: "81f18226-d36e-4a0e-bd0e-b936843ae77b}", url: "${url}"]]])
                // sh 'mkdir -p configs'
                //dir('configs') {
               //     git branch: "${params.RELEASE_VERSION}", credentialsId: '81f18226-d36e-4a0e-bd0e-b936843ae77b', url: '${url}'
                //}
                git branch: "${params.RELEASE_VERSION}", credentialsId: '81f18226-d36e-4a0e-bd0e-b936843ae77b', url: "${url}"
                
                echo "---------------------------------------------------------------------------------"
                echo "Starting Config Application......"
                echo "---------------------------------------------------------------------------------"
                script {
                    wrap([$class: 'BuildUser']) {
                    def deploylog="${BUILD_USER} use pipeline  '${JOB_NAME}(${BUILD_NUMBER})' "
                    println deploylog
                    buildName "#${BUILD_NUMBER}-^${params.RELEASE_VERSION}^-${BUILD_USER}"
                    HTTPD_LOCATION= sh(  returnStdout: true, script: 'git show -s  |grep -vE "commit|Date" |grep -v "^$"')
                    //echo "HTTPD_LOCATION =${HTTPD_LOCATION}"
                    buildDescription "${HTTPD_LOCATION}" 
                  }
                }
                script {
                    sh """
                       
                        echo "pwd"
                        pwd
                        echo "删除原算法文件"
                        #rm -rf /data1/TestPackage/lung/cta/lung/*
                        #cp -rf ./* /data1/TestPackage/lung/cta/lung/
                        #cp /data1/TestPackage/lung/cta/lung/path.conf /data1/TestPackage/lung/cta/lung/path_reset.conf

                       
                       # echo base image name: ${DOCKER_IMAGE}
                       # echo image name: harbor.deepwise.com/${JOB_NAME}:${Tag}
                       # echo FROM harbor.deepwise.com/${DOCKER_IMAGE} > Dockerfile
                       # echo COPY aiserver /root/aiserver >> Dockerfile
                       # echo harbor.deepwise.com/${JOB_NAME}:${Tag}
                       # cat Dockerfile
                       # docker build -t harbor.deepwise.com/${JOB_NAME}:${Tag} --no-cache .

                      """

                }


        }

    }
}
}

贴一下checkout的流水线的修改方式

#!groovy

pipeline {
    agent {
        label "172.16.40.245"
    }

    //定义构建参数
    parameters {
        choice(name: '发布环境', choices: ['DxAI-Prod'], description: '请选择需要发布的环境')
        gitParameter name: 'BRANCH', type: 'PT_BRANCH_TAG', branchFilter: '(.*\\b)', listSize: '10', defaultValue: '20220531_sp2', selectedValue: 'TOP', sortMode: 'DESCENDING'
        imageTag(name: 'DOCKER_IMAGE', description: '',
            image: 'base/lung', filter: '.*', defaultTag: 'ge930',
             registry: 'http://10.10.3.246', credentialId: '18060a85-ebcf-4aa4-bca7-b267c07497f3', tagOrder: 'NATURAL') 
    }

    //定义变量
    environment {
        Unzip_Path="/data1/TestPackage/lung/cta/"
        Tag = "`date '+%Y-%m-%d-%H'-${BUILD_NUMBER}`"
        // 项目名称
        // PROJECT = 'DxAI'
        // 工程名称
        // APP_NAME = "dxPython"
        // 发布环境
        // DEPLOY_ENV = "${params.发布环境}"
        // 仓库地址
        // GIT_REPO = "${params.GIT_REPO}"
        // 仓库分支
        // BRANCH = "${params.BRANCH}"
        // 备份路径
        // BAK_PATH = "/mnt/backup/"
        // 模块路径
        // APP_PATH = "/data1/docker_data/wwwroot/research"
        //默认邮件接收人
        // DEFAULT_EMAIL = ''
        //负责邮件接收人
        // OWNER_EMAIL = ''
        //PL邮件接收人
        // PL_EMAIL = ' '
    }

    //来源全局设置配置的变量
//     tools {
// //        jdk 'java-8'
//         maven 'maven-3.6.0'
//     }

    options {
        timestamps()
        //保持构建的最大个数
        buildDiscarder(logRotator(numToKeepStr: '10'))
    }




    //执行任务模块
    stages {
        //拉取代码模块
        stage('Checkout') {
            steps {
                deleteDir()
                echo "---------------------------------------------------------------------------------"
                echo "Starting Checkout Code......"
                echo "---------------------------------------------------------------------------------"
                script {
                    echo "starting fetchCode from ${url}"
                    checkout([$class           : 'GitSCM',
                              branches         : [[name: "${BRANCH}"]],
                              extensions: [[$class: 'CloneOption', noTags: false, reference: '', shallow: false, timeout: 100]],
                              userRemoteConfigs: [[credentialsId: '81f18226-d36e-4a0e-bd0e-b936843ae77b',
                                                   url          : "${url}",]]
                    ])
                }
            }
        }

        //打包模块
        stage('Package') {
            steps {
                echo "---------------------------------------------------------------------------------"
                echo "Starting Gradlew package ......"
                echo "---------------------------------------------------------------------------------"
                script {
                    sh """
                        echo "package"
                       """
                }
            }
        }

        stage('Publish') {
            steps {
                echo "---------------------------------------------------------------------------------"
                echo "Starting Publish apk to Remote ......"
                echo "---------------------------------------------------------------------------------"
                // script {
                //     sshPublisher(publishers:
                //             [sshPublisherDesc(configName: "$DEPLOY_ENV",
                //                     transfers: [sshTransfer(cleanRemote: false,
                //                             excludes: '',
                //                             execCommand: 'ls /tmp/dxPython*',
                //                             execTimeout: 120000,
                //                             flatten: false,
                //                             makeEmptyDirs: false,
                //                             noDefaultExcludes: false,
                //                             patternSeparator: '[, ]+',
                //                             remoteDirectory: '/tmp',
                //                             remoteDirectorySDF: false,
                //                             removePrefix: '',
                //                             sourceFiles: 'dxPython.tgz')],
                //                     usePromotionTimestamp: false,
                //                     useWorkspaceInPromotion: false,
                //                     verbose: false)])
                // }
            }
        }

        stage('Install') {
            agent {
                label "172.16.40.245"
            }
            steps {
                echo "---------------------------------------------------------------------------------"
                echo "Starting Install Application......"
                echo "---------------------------------------------------------------------------------"
                script {
                    sh """
                        echo 123
                       """
                }
            }
        }
    }
}

修改jenkins启动配置 全局修改

https://vqiu.cn/jenkins2-git-timeout/

https://blog.csdn.net/wanglei_storage/article/details/78105763

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐