lhupfeldt / jenkinsflow

Python API with high level build flow constructs for jenkins/hudson
BSD 3-Clause "New" or "Revised" License
13 stars 4 forks source link

Pipeline jobs executed in parallel end up running the same build #24

Closed lechat closed 9 years ago

lechat commented 9 years ago

I created simple test pipeline and execute two instances of it in parallel. When job is scheduled by one pipeline, but job status is QUEUED second pipeline will "attach" to that build instead of scheduling another build. Once job has RUNNING status - both pipelines will report the same build number.

I would expect that if build is queued the pipeline still try to schedule another build.

Thanks!

Aleksey

lhupfeldt commented 9 years ago

Hi Aleksey,

That sounds strange, since jenkinsflow uses the queue item url returned from 'build...', to determine the build number. That was part of the major refactoring to allow simultaneous running of the same flow. Can you send me a minimal example? Which jenkins version are you using?

Regards Lars

lechat commented 9 years ago

Jenkins ver. 1.532.2

Example code:

"""
Usage:
    pipeline.py TARGET_HOST --jenkinsurl URL --jenkinsuser USER --jenkinstoken TOKEN

Options:
    --help                  This screen
    --jenkinsurl URL        URL of Jenkins to use
    --jenkinsuser USER      Jenkins user
    --jenkinstoken TOKEN    Jenkins user authentication token
"""
from docopt import docopt
from jenkinsflow.flow import serial

def main(api):
    with serial(api, timeout=570, report_interval=3, require_idle=False) as outer_ctrl:
        outer_ctrl.invoke('test_jenkinsflow')

if __name__ == '__main__':
    args = docopt(__doc__)

    from jenkinsflow.jenkins_api import Jenkins
    jenkins = Jenkins(args['--jenkinsurl'], username=args['--jenkinsuser'],
                      password=args['--jenkinstoken'])
    main(jenkins)

The job is simple one - shell:

uname -a
sleep 30
uname -a
sleep 30
lhupfeldt commented 9 years ago

Thank you, I will look at it tonight.

Regards / Venlig Hilsen Lars Hupfeldt Nielsen Hupfeldt IT

Phone: +45 2060 3546

2014-10-16 11:09 GMT+02:00 Aleksey Maksimov notifications@github.com:

Jenkins ver. 1.532.2

Example code:

"""Usage: pipeline.py TARGET_HOST --jenkinsurl URL --jenkinsuser USER --jenkinstoken TOKEN Options: --help This screen --jenkinsurl URL URL of Jenkins to use --jenkinsuser USER Jenkins user --jenkinstoken TOKEN Jenkins user authentication token"""from docopt import docoptfrom jenkinsflow.flow import serial

def main(api): with serial(api, timeout=570, report_interval=3, require_idle=False) as outer_ctrl: outer_ctrl.invoke('test_jenkinsflow') if name == 'main': args = docopt(doc)

from jenkinsflow.jenkins_api import Jenkins
jenkins = Jenkins(args['--jenkinsurl'], username=args['--jenkinsuser'],
                  password=args['--jenkinstoken'])
main(jenkins)

The job is simple one - shell:

uname -a sleep 30 uname -a sleep 30

— Reply to this email directly or view it on GitHub https://github.com/lhupfeldt/jenkinsflow/issues/24#issuecomment-59333973 .

lhupfeldt commented 9 years ago

Hi Aleksey,

I'm unable to reproduce. I'm on Jenkins 1.567 on Fedora 20. Could you try to add some debug to jenkins_job.ApiJob.invoke: print("response.location:", response.location) If you get the same location it is a jenkins bug. If you get different locations and jenkinsflow looses track of the correct build, then it is a jenkinsflow bug. You could also try to update jenkins.

Regards Lars

lechat commented 9 years ago

Hi, Lars

I can't update Jenkins due to some changes in Jenkins, that I know will break my setup. I use custom credentials plugin and it is not very easy to change core plugins in latest Jenkins. So I have to wait till my changes will be in next Jenkins release (they already merged, but plugin version is not yet available).

I will try your suggestion now.

lechat commented 9 years ago

I've got the same location... Jenkins bug :(

lhupfeldt commented 9 years ago

I will close this now, let me know when you upgrade if the issue is resolved.