Git operations occasionally hang in Jenkins on Windows

点点圈 提交于 2019-12-03 05:20:33
Ulo Lava

I solved it by:

  • setting the Path to Git executable to C:\Program Files (x86)\Git\cmd\git.exe (i.e. cmd and not bin!) and
  • by setting the environment variable %HOME% to $USERPROFILE
    (otherwise HOME defaults to $HOMEDRIVE$HOMEPATH, which was H:\ in my case, but typically $HOME is set to $USERPROFILE).
gliptak

This is discussed at:

https://issues.jenkins-ci.org/browse/JENKINS-5413

You might run the script below in the Script Console:

Jenkins.instance.getTrigger("SCMTrigger").getRunners().each()
{
  item ->
    println(item.getTarget().name)
    println(item.getDuration())
    println(item.getStartTime())
    long millis = Calendar.instance.time.time - item.getStartTime()

    if(millis > (1000 * 60 * 3)) // 1000 millis in a second * 60 seconds in a minute * 3 minutes
    {
      Thread.getAllStackTraces().keySet().each()
      { 
        tItem ->
          if (tItem.getName().contains("SCM polling") && tItem.getName().contains(item.getTarget().name))
          { 
            println "Interrupting thread " + tItem.getName(); 
            tItem.interrupt()
          }
       }
    }
}

to at least clear up the issue ...

tomgi

In my case downloading plink from the PuTTY site and setting the GIT_SSH environment variable to use it solved the problem.

Josh Santangelo

I may have solved this. I originally set up my SSH keys by generating them with ssh-keygen on a Linux machine. This generally worked, but Git would hang occasionally from Jenkins.

Now I've tried using the PuTTY tools to set up key-based authentication to my Git servers, using these instructions. I then set the GIT_SSH environment variable to the path to plink.exe. It seems to be working now, but it was always an intermittent issue. Hopefully it won't return...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!