Skip to content

Return exit code based on job result if -x switch is on #39

Open

Description

@radomirbosak

jenkins console -x JOBNAME or jenkins console --exit-code JOBNAME could return a (non)-zero exit code depending on whether the job failed or not.

This will allow people to include the jenkins tool in their workflow and decide differently based on the job status, e.g.

if jenkins console -i -x myjob; then
   echo "Hurray"
else
   echo -e "Subject: Something went wrong \n\n with our job. please help" | sendmail  problem@example.com 
fi

I know this is already kind-of possible by greeping for SUCCESS or FAIL in the console output, but that's not reliable. Moreover a simple CLI switch looks more elegant and is less prone to typos.

The jenkins info subcommand could use the same switch too.

Activity

  1. LD250 commented on Jun 13, 2017

    @LD250
    Owner

    @radomirbosak do we need a console output in this case?

    Maybe it is better to do this in start command?

    Something like:
    jenkins start job_name --wait-until-done

    What do you think?

  2. radomirbosak commented on Aug 24, 2017

    @radomirbosak
    ContributorAuthor

    Actually yes, your suggestion makes more sense. Let's do it like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions