Pass return value of script back to incus exec

This might be a bad idea, but I am running into an issue.

I am running a Jenkins job that runs something like this.

incus exec my-container -- su -l my-user -c './my-script.sh'

If my script fails with a non-zero return value. The Incus command still returns with a success. This makes the Jenkins job succeed.

Any idea how to pass the non-zero return value to Incus exec and then fail the Jenkins job?

Does anyone have another idea that could solve the issue in a more sane way?

Are you sure? I just tested that on Ubuntu 24.04 container with ./my-script.sh:

#!/bin/bash
exit 1

I run:

$ incus exec my-container -- su -l ubuntu -c "./my-script.sh"
$ echo $?
1

This command gave me the same result:

incus exec tools -- sudo --login --user ubuntu bash -c "./my-script.sh"

Thanks for the reality check. :slight_smile:

You helped me find my mistake.

In my infinite debugging wisdom I was doing something similar to this:

false || echo $?

:laughing: