Home > Mobile >  Jenkins build hangs on 'git pull'?
Jenkins build hangs on 'git pull'?

Time:09-16

I am using a Jenkins declarative pipeline to build from a remote repo. In order to do so, I have an 'Update' stage, which looks like this:

stage('Update') {
    steps {
        echo 'Starting update...'
            
        dir ('C:/Program Files (x86)/Jenkins/workspace/Bootloader/_RELEASE_SCRIPTS') {
            powershell './_RUN_STAGE.ps1 -stage 0'
        }
        
        echo 'DONE!'
    }
}

_RUN_STAGE.ps1 is a script which calls .sh scripts through an MSYS2 console, so it's contents are irrelevant. The first script it calls is _UPDATE_ALL.sh, which looks like this:

#!/bin/sh

echo $(git stash)
echo $(git pull)
echo $(git submodule update --force --init --recursive)
echo $(git fetch --all)
echo $(git tag -l | xargs git tag -d)
echo $(git fetch --tags)

After 'git stash' is run, the Jenkins build hangs. I know this, because this is the output log:

Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\Bootloader
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Update)
[Pipeline] echo
Starting update...
[Pipeline] dir
Running in C:/Program Files (x86)/Jenkins/workspace/Bootloader/_RELEASE_SCRIPTS
[Pipeline] {
[Pipeline] powershell
STAGE: UPDATE.
No local changes to save

'No local changes to save' is returned from 'git stash', which in my eyes means that it is 'git pull' that hangs the build. Why? Additionally, running the _UPDATE_ALL.sh script manually works exactly as expected, only when I run it through Jenkins does it hang.

NOTE: This question may be similar to this one, but I can not extract any useful info from it, hence why I ask this.

CodePudding user response:

Does the job have the GitLFSPull extension enabled? When the GitLFSPull extension is enabled, the git checkout should not need to authenticate because the necessary large files are already available locally. Early implementations of the smudge filter were slow, so the git plugin chooses to call git lfs pull directly. If there is not a call to git lfs pull in the job log, then that may indicate some other problem.

CodePudding user response:

I was able to circumvent this, by instead of issuing my git commands in a .sh script which is called through Jenkins, just directly calling them in the Jenkinsfile with 'powershell "git stash"' and so on, like this:

stage('Update') {
    steps {
        echo 'Starting update...'
        
        powershell 'git stash'
        powershell 'git pull origin master'
        powershell 'git submodule update --force --init --recursive'
        powershell 'git fetch --all'
        powershell 'git tag -l | %{git tag -d $_}'
        powershell 'git fetch --tags'
        
        echo 'DONE!'
    }
}

While this solved my problem, it did not provide an explanation as to why 'git pull' hangs the build if called from a script. Any insight is welcome!

  • Related