nuget.exe推送引发错误。基础连接已关闭:连接意外关闭

时间:2019-07-11 15:20:52

标签: jenkins jenkins-plugins nexus

我在一个文件夹中创建了几个nuget包,我正尝试将其从jenkins发布到Nexus。下面是我的阶段代码:

stage('Publish To Nexus') {
    when {
        branch 'dev'
    }
    steps {
        parallel (
            "Publish Application Packages": {
                script {
                    bat "nuget.exe push \"${PACKAGE_PATH}\\*.nupkg\"  ${NEXUS_APIKEY} -Source \"${FEED_URL}\" -Timeout 36000"
                }
            },
            "Publish Upgrader Packages": {
                script {
                    bat "nuget.exe push \"${PACKAGE_PATH_UPGRADER}\\*.nupkg\" ${NEXUS_APIKEY} -Source \"${FEED_URL}\"  -Timeout 36000"
                }
            }
        )
    }
}

但是,它失败并出现错误(特别是对于大文件大小):

An error occurred while sending the request.
The underlying connection was closed: The connection was closed unexpectedly.

要注意的一点:当我一次手动执行命令时,它可以正常上传。需要帮助,以了解通过jenkins将软件包上传到nexus的更好方法或替代方法。

1 个答案:

答案 0 :(得分:0)

我通过放置retrytimeout解决了这个问题。

steps {
    script {
        echo "Publishing packages"
        retry(3) {
            timeout(time: 30, unit: 'MINUTES') {
                echo "Publish large file."
                bat "_________"
            }
        }
    }
}