您的位置 首页 linux 运维

jenkins 设置 git 超时时间

jenkins 设置 git 超时时间

0: 实用方法:

1. 全局设置 Git 超时时间

通过 Jenkins 管理界面设置

进入 Manage Jenkins → Configure System
找到 Git plugin 部分
在 Global Config 区域设置:
http.timeout = 3600 (单位:秒)
https.timeout = 3600 (单位:秒)

 

2. 通过环境变量设置

environment {
    GIT_TIMEOUT = '3600'
}

stage('Checkout') {
    steps {
        sh '''
            git -c http.timeout=${GIT_TIMEOUT} clone your-repo-url
        '''
    }
}

3. 命令行参数设置

# 在执行 Git 命令时直接设置
git -c http.timeout=3600 fetch --tags --force --progress your-repo-url

 

4 在 Pipeline 中设置超时

pipeline {
    agent any
    
    options {
        timeout(time: 60, unit: 'MINUTES')
    }
    
    stages {
        stage('Checkout') {
            steps {
                git(
                    url: 'your-repo-url',
                    credentialsId: 'your-credentials',
                    branch: 'main',
                    extensions: [
                        [$class: 'CloneOption', timeout: 60] // 60分钟
                    ]
                )
            }
        }
    }
}

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章