简体   繁体   中英

Jenkins on Windows gets stuck on Fabric remote command when deploying Python app

I have this Jenkins build configuration for my Django application in "Execute Windows batch command" field:

// Code is downloaded using Git plugin 
virtualenv data/.venv
call data/.venv/Scripts/activate.bat
pip install -r requirements/local.txt

cd src/
python .\manage.py test

cd ..
fabric dev deploy // Build job get stuck here

All steps work OK except the last one. Jenkins gets stuck on first Fabric attempt to connect to remote server. In "Console output" is spinner keep spinning and I need to kill build manually.

When I run Fabric task manually from CLI, it works. I read about some problems with Jenkins+known_hosts, so I tried env.reject_unknown_hosts = True in fabfile to see if there is "Add to authorized keys" question.

Fabfile is pretty standard, nothing special:

@task
def dev():
    env.user = "..."
    env.hosts = "..."
    env.key_filename = "..."
    nv.reject_unknown_hosts = True


@task
def deploy():
    local("python src/manage.py check") # <---- OK, output is in Jenkins

    run('git reset --hard') # <---- Jenkins will freeze
    run('git pull --no-edit origin master')

    # etc ....

    print("Done.")

These requires a password, the process is probbaly stuck asking for user's password.

Add --no-pty to the command to make sure it's not blocking and reporting the error. It is than solved based o your specific remote/ssh/tty setup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM