詹金斯:hudson.plugins.git.GitException:命令“git fetch --tags --progress origin 返回状态码143:
Posted
技术标签:
【中文标题】詹金斯:hudson.plugins.git.GitException:命令“git fetch --tags --progress origin 返回状态码143:【英文标题】:Jenkins: hudson.plugins.git.GitException: Command "git fetch --tags --progress origin returned status code 143: 【发布时间】:2019-04-12 10:06:56 【问题描述】:我无法在 Jenkins 中构建作业,因为我在构建日志中收到“状态代码 143:”错误。根据这个jenkins bug page,该错误与repo 的获取时间超过10 分钟有关。因此,作为一种解决方案,我更改了一些选项以加快获取速度,它们是:取消选中“获取标签”,选中“浅克隆”和“浅克隆深度”设置为 1 和“超时(克隆和获取操作以分钟为单位) " 设置为 20。
我正在附加我的配置here
This 是来自 Jenkins 的构建日志:
这是我在 repo 中的 Jenkinsfile,由于超时设置为 10 分钟,我认为 jenkins 无法达到这一点,我无法更改:
// Deployment template for CMS-based websites (Drupal or Wordpress)
//
//
pipeline
agent any
parameters
choice(choices: "Dev\nStaging\nProduction", description: "Choose which environment to push changes to.", name: "DEPLOY_TO")
choice choices: "No\nYes", description: "Choose whether to deploy the database as well.", name: "DEPLOY_DB"
environment
SITEID = "ge"
NOFLAGS = "0"
DBNAME = "wpress_website"
DBSERVER = "dbserver"
DBUSER = "geWordpress"
DBPASS = "akjh23kas"
EXCLUDE = "comp_commentmeta,comp_comments" // separate multiple tables with commas
DEPLOY_TO = "$params.DEPLOY_TO"
DEPLOY_DB = "$params.DEPLOY_DB"
stages
stage("deploy-db-dev")
when
allOf
environment ignoreCase: true, name: "DEPLOY_TO", value: "dev";
environment ignoreCase: true, name: "DEPLOY_DB", value: "yes";
steps
// this stage only required until we make our dev the master DB
// copy full dev database from appserv1
// import latest database dump to dev server
script
FILENM = sh(script: 'ls -t goewp-s-dump* | head -1', returnStdout: true)
//Fixing the problem with the collation existing in the sql dump file, refer to: https://***.com/questions/42385099/1273-unknown-collation-utf8mb4-unicode-520-ci
//apparently, this is due to a version of mysql issue. Once the problem is fixed from the server side we can then remove the following lines.
sh "sed -i s/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g $FILENM"
//The following line was added because the site is pointing to a staging server which we don't have control over, again, once this is fixed we can delete the following line of code.
sh "sed -i s/edit.staging.websites.3pth.com/stage.goewpfoods.hcgweb.net/g $FILENM"
sh "mysql -h appserver -u $env.DBUSER --password='$env.DBPASS' $env.DBNAME_dev < $WORKSPACE/$FILENM"
stage("deploy-dev")
when
environment ignoreCase: true, name: "DEPLOY_TO", value: "dev"
steps
// copy files to appserv2
// NOTE: if we move the repo to SVN, we should change httpdocs/ to $env.SITEIDdocs/
sh "sudo chown jenkins:jenkins *"
//Replace the wp-config.php file with our comp file with our information.
sh "/bin/cp httpdocs/wp-config-comp.php httpdocs/wp-config.php"
// prepare the dev server to receive files by changing the owner
sh "ssh webadmin@appserv2 \"sudo chown -R webadmin:webadmin /var/opt/httpd/$env.SITEIDdocs/\""
// copy files from control server to dev
sh "rsync --exclude=Jenkinsfile -rav -e ssh --delete $WORKSPACE/httpdocs/ webadmin@appserv2:/var/opt/httpd/$env.SITEIDdocs/"
// fix the owner/permissions on the dev server
sh "ssh webadmin@appserv2 \"sudo chown -R apache:$env.SITEID-web /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@appserv2 \"sudo chmod -R g+w /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@appserv2 \"sudo find /var/opt/httpd/$env.SITEIDdocs/ -type d -exec chmod g+s \\;\""
stage("deploy-db-staging")
when
allOf
environment ignoreCase: true, name: "DEPLOY_TO", value: "staging";
environment ignoreCase: true, name: "DEPLOY_DB", value: "yes";
steps
script
def myexcludes = env.EXCLUDE.split(',').toList()
MYFLAGS = "-Q -K -c -e --default-character-set=utf8 "
if (env.NOFLAGS == "0")
myexcludes.each
MYFLAGS = "$MYFLAGS --ignore-table=$env.DBNAME_dev.$it"
sh "cd $WORKSPACE"
// pull a backup of the current dev database (may exclude some tables)
sh "mysqldump -h appserv2 -u $env.DBUSER --password='$env.DBPASS' $env.DBNAME_dev $MYFLAGS > $env.DBNAME_dev.sql"
// create a backup copy of the current staging database (full backup)
sh "mysqldump -h $env.DBSERVER -u $env.DBUSER --password='$env.DBPASS' $env.DBNAME_stage > $env.DBNAME_stage_bak.sql"
// upload the dev database dump to the staging database
sh "mysql -h $env.DBSERVER -u $env.DBUSER --password='$env.DBPASS' $env.DBNAME_stage < $WORKSPACE/$env.DBNAME_dev.sql"
stage("deploy-staging")
when
environment ignoreCase: true, name: "DEPLOY_TO", value: "staging"
steps
// copy files from dev to control server
sh "rsync --exclude=.svn --exclude=.git -rav -e ssh webadmin@appserv2:/var/opt/httpd/$env.SITEIDdocs/ /tmp/$env.SITEIDdocs/"
//Replace the wp-config.php file with our comp file with our information.
sh "/bin/cp httpdocs/wp-config-comp.php httpdocs/wp-config.php"
// prepare the staging server to receive files by changing the owner
sh "ssh webadmin@stageserv \"sudo chown -R webadmin:webadmin /var/opt/httpd/$env.SITEIDdocs/\""
// copy files from control server to staging
sh "rsync --exclude=.svn --exclude=.git -rav -e ssh --delete /tmp/$env.SITEIDdocs/ webadmin@stageserv:/var/opt/httpd/$env.SITEIDdocs/"
// fix the owner/permissions on the staging server
sh "ssh webadmin@stageserv \"sudo chown -R apache:$env.SITEID-web /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@stageserv \"sudo chmod -R g+w /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@stageserv \"sudo find /var/opt/httpd/$env.SITEIDdocs/ -type d -exec chmod g+s \\;\""
// delete the temporary files on the control server
sh "rm -Rf /tmp/$env.SITEIDdocs/"
// clear the caches
sh "wget -O - \"http://www.web.net/incacache.php?api_key=yoiVbjgtL&site_id=088\""
stage("deploy-db-production")
when
allOf
environment ignoreCase: true, name: "DEPLOY_TO", value: "production";
environment ignoreCase: true, name: "DEPLOY_DB", value: "yes";
steps
script
def myexcludes = env.EXCLUDE.split(',').toList()
MYFLAGS = "-Q -K -c -e --default-character-set=utf8 "
if (env.NOFLAGS == "0")
myexcludes.each
MYFLAGS = "$MYFLAGS --ignore-table=$env.DBNAME_stage.$it"
sh "cd $WORKSPACE"
// pull a backup of the current staging database (may exclude some tables)
sh "mysqldump -h $env.DBSERVER -u $env.DBUSER --password='$env.DBPASS' $env.DBNAME_stage $MYFLAGS > $env.DBNAME_stage.sql"
// create a backup copy of the current production database (full backup)
sh "mysqldump -h $env.DBSERVER -u $env.DBUSER --password='$env.DBPASS' $env.DBNAME_prod > $env.DBNAME_prod_bak.sql"
// upload the staging database dump to the production database
sh "mysql -h $env.DBSERVER -u $env.DBUSER --password='$env.DBPASS' $env.DBNAME_prod < $WORKSPACE/$env.DBNAME_stage.sql"
stage("deploy-production")
when
environment ignoreCase: true, name: "DEPLOY_TO", value: "production"
steps
// copy files from staging to control server
sh "rsync --exclude=.svn --exclude=.git -rav -e ssh webadmin@stageserv:/var/opt/httpd/$env.SITEIDdocs/ /tmp/$env.SITEIDdocs/"
// prepare the production server to receive files by changing the owner
sh "ssh webadmin@appserv3 \"sudo chown -R webadmin:webadmin /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@appserv4 \"sudo chown -R webadmin:webadmin /var/opt/httpd/$env.SITEIDdocs/\""
// copy files from control server to production
sh "rsync --exclude=.svn --exclude=.git -rav -e ssh --delete /tmp/$env.SITEIDdocs/ webadmin@appserv3:/var/opt/httpd/$env.SITEIDdocs/"
sh "rsync --exclude=.svn --exclude=.git -rav -e ssh --delete /tmp/$env.SITEIDdocs/ webadmin@appserv4:/var/opt/httpd/$env.SITEIDdocs/"
// fix the owner/permissions on the production server
sh "ssh webadmin@appserv3 \"sudo chown -R apache:$env.SITEID-web /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@appserv4 \"sudo chown -R apache:$env.SITEID-web /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@appserv3 \"sudo chmod -R g+w /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@appserv4 \"sudo chmod -R g+w /var/opt/httpd/$env.SITEIDdocs/\""
sh "ssh webadmin@appserv3 \"sudo find /var/opt/httpd/$env.SITEIDdocs/ -type d -exec chmod g+s \\;\""
sh "ssh webadmin@appserv4 \"sudo find /var/opt/httpd/$env.SITEIDdocs/ -type d -exec chmod g+s \\;\""
// delete the temporary files on the control server
sh "rm -Rf /tmp/$env.SITEIDdocs/"
// clear the caches
sh "wget -O - \"http://www.web.net/incacache.php?api_key=yoiVbjgtL&site_id=088\""
对此的任何帮助将不胜感激!
【问题讨论】:
真正的问题是:为什么需要10多分钟才能获取? @AndréDS 是一个大仓库,大约 3GB 考虑将您的构建日志和 Jenkinsfile 直接粘贴到这个问题中。链接已失效。 @KenRachynski 感谢您指出这一点。我刚刚用正确的链接更新了帖子。 【参考方案1】:大家都知道,我的问题与我拥有的 Jenkins 版本 (2.129) 中的一个错误有关。我只需要取消选中作业配置中的“轻量级结帐”选项。问题似乎出在 Bitbucket 上,它尝试进行 API 调用以首先检索 Jenkinsfile,但它没有得到来自 bitbucket 的任何响应并且它超时。希望这对遇到同样问题的其他人有所帮助
【讨论】:
以上是关于詹金斯:hudson.plugins.git.GitException:命令“git fetch --tags --progress origin 返回状态码143:的主要内容,如果未能解决你的问题,请参考以下文章