jenkins shall fail on errors during rpm install job

I have an deployment task that is executed on my test machine. The purpose is to test the freshly build rpm from jenkins on the very same machine.

Therefore I set up a deploy job in jenkins that executes the following shell lines:

  • Pyexcel_xlsx successfully installed but importing is still on syntax error
  • How do I count total lines of remote git repository
  • How do I pass an absolute path to the adb command via git bash for windows?
  • unable to look up https fatal error when push to git repository
  • SVN / Git / Bash
  • Is it possible to pre-evaluate a value in bash's PS1?
  • artifact=$(ls build/*.rpm | head -1)
    sudo /usr/local/sbin/jenkins-rpm-install $artifact
    rm -rf build/

    To install the rpm I made a small shell script that jenkins has exclusive sudo permissions for.

    # allows jenkins to install rpm as privileged user
    # add the following line to /etc/sudoers:
    # jenkins    ALL = NOPASSWD: /usr/local/sbin/jenkins-rpm-install
    rpm -vv --install --force $artifact

    Now I have the problem: Whenever the rpm install fails jenkins does not recognize the error code and marks the build as success.

    Does anyone have an idea how to properly solve this?
    Also tips to improve this process are welcome.

  • “git --bare init” does not produce just a .git directory
  • git - setting path variable
  • Delete all local git branches
  • Get access to Build Changelog in Jenkins
  • Git: Show content of file as it will look like after committing
  • How to make a script to perform git pull?
  • 2 Solutions collect form web for “jenkins shall fail on errors during rpm install job”

    What about simply checking for rpm error’s code in your script and report it to Jenkins yourself?

    rpm -vv --install --force $artifact
    if [[ err_code > 0 ]]; then exit $?; fi

    Or with overload:

    rpm -vv --install --force $artifact || exit $?

    If within configuration you are using execute shell step Jenkins will mark build as failed if exit code!= 0.

    If might be sufficient to alter your script by adding exit $? at the end.

    Git Baby is a git and github fan, let's start git clone.