pycontribs / jenkinsapi

A Python API for accessing resources and configuring Hudson & Jenkins continuous-integration servers
http://pypi.python.org/pypi/jenkinsapi
MIT License
858 stars 485 forks source link

A Build that has been polled while is_running will not transition to is_good #689

Closed stuhood closed 5 years ago

stuhood commented 5 years ago
ISSUE TYPE
Jenkinsapi VERSION

0.3.8

Jenkins VERSION

2.150.2

SUMMARY

A single Build object (as returned by Job.get_build(buildid)) will transition from is_running to not is_running, but it will not transition from not is_good to is_good at the same time.

A small repro of this looks like:

>>> j = get_jenkins_job('my-job')
>>> b = j.get_build(22)
>>> import time
>>> while True:
...   time.sleep(1.0)
...   print(b.is_running(), b.is_good())
...
(True, False)
(True, False)
(True, False)
(False, False)
(False, False)
(False, False)
(False, False)
(False, False)
^CTraceback (most recent call last):
  File "<console>", line 2, in <module>
KeyboardInterrupt
>>> b = j.get_build(23)
>>> print(b.is_running(), b.is_good())
(False, True)

In short: the job is initially running, but completes at some point. But when it completes, is_good does not begin to return the final result for the build. If you recreate the Build object, you see the final result for the build.

EXPECTED RESULTS

I would expect that when not is_running, the final result/status of the job would be visible via is_good.

ACTUAL RESULTS

See above.

miaoxiaoy commented 5 years ago

i have same problem

ryan4yin commented 5 years ago

I think the problem is this function in class Build:

    def get_status(self):
        return self._data["result"]

Once build is instantiated, the status is not automatically refreshed by call poll.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

Closed due to inactivity