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

Jenkinsflow returns SUCCESS when flow has failed #25

Closed lechat closed 8 years ago

lechat commented 9 years ago

Hi, Lars

One of the jobs in flow has failed, but the job, that runs flow itself shows that flow failed, but still returns success. How do I fail flow job when flow has failed?

--- Final status ---
serial flow: [
   serial flow: [
      job: 'JOB_1' SUCCESS
      job: 'LONG_JOB' FAILURE  http://jenkins/jenkins/job/LONG_JOB/208/console
      job: 'JOB_2' UNKNOWN - IDLE 
   ]

   parallel flow: (
      serial flow: [
         job: 'JOB_3' UNKNOWN - IDLE 
         job: 'JOB_4' UNKNOWN - IDLE 
      ]

      serial flow: [
         job: 'JOB_5' UNKNOWN - IDLE 
         job: 'JOB_6' UNKNOWN - IDLE 
      ]

   )

]

Finished: SUCCESS

Note that flow failed, but jenkinsflow still returns "SUCCESS" instead of "FAILURE".

Is there something I miss?

lechat commented 9 years ago

This code in flow.py::_TopLevelControllerMixin.wait_for_jobs() is never executed...

if self.result == BuildResult.UNSTABLE:
            set_build_result(self.username, self.password, 'unstable', direct_url=self.top_flow.direct_url)

Also, set_build_result() relies on Jenkins CLI jar to be in $WORKSPACE, but I can't see what triggers download_cli() anywhere in the code...

lechat commented 9 years ago

The version from master fails build properly, but I can't use it because it has numerous places, where it refers to self.result.name and self.result is int...

flow.py: lines 679, 365, 447, 316

lhupfeldt commented 9 years ago

Hi Aleksey,

The line numbers you show do not seem to point to any lines with self.result.name!

What do you mean by you can't use it beause...? Are you seing an actual error or are you assuming there is an error? I'm pretty sure result is not int, it is an Enum value. Maybe it is pylint telling you that it is int? pylint's understanding of Enum is not very good.

Regarding if self.result == BuildResult.UNSTABLE: not being executed: BuildResult.UNSTABLE normally only happens when using test plugins (junit) where test cases fail. A failed job will have BuildResul.FAILURE. You can ask jenkinsflow to propagate BuildResul.UNSTABLE from a failed job to the job running the flow, or you can use jenkinflow set_build_result ... from inside a job shell step to change the result to BuildResult.UNSTABLE.

Is the testsuite running correctly against your version of Jenkins?

lhupfeldt commented 9 years ago

Hi Aleksey,

Any more info about your issue?

lhupfeldt commented 8 years ago

No more info, closing.