canonical / snapcraft

Package, distribute, and update any app for Linux and IoT.
https://snapcraft.io
GNU General Public License v3.0
1.18k stars 443 forks source link

`snapcraft remote-build` succeeds even if the build fails #5080

Open barrettj12 opened 1 week ago

barrettj12 commented 1 week ago

Bug Description

snapcraft remote-build will return an exit code of 0 even if the remote build fails. This makes it hard to use in automated scripts, as the return value cannot be used to determine if the build succeeded. It should return a non-zero exit value if the operation fails, in line with Unix conventions.

To Reproduce

snapcraft remote-build --launchpad-accept-public-upload --build-on="amd64,arm64,ppc64el,s390x"

Environment

Running on an AWS instance in Jenkins. Ubuntu Focal, amd64. Snapcraft 7.5.6.

snapcraft.yaml

https://github.com/juju/juju/blob/3.5/snap/snapcraft.yaml

Relevant log output

12:21:20 Build status as of 2024-09-30 17:21:20.064750:
12:21:20    arch=s390x  state=Currently building
12:21:20    arch=ppc64el    state=Currently building
12:21:50 Build status as of 2024-09-30 17:21:50.664508:
12:21:50    arch=s390x  state=Failed to build
12:21:50    arch=ppc64el    state=Failed to build
12:21:51 Starting Snapcraft 7.5.6
12:21:51 Logging execution to '/home/jenkins/.local/state/snapcraft/log/snapcraft-20240930-171430.461014.log'
12:21:51 Snap file not available for arch 's390x'.
12:21:52 Build log available at 'juju_s390x.txt'
12:21:52 Build failed for arch 's390x'.
12:21:52 Snap file not available for arch 'ppc64el'.
12:21:53 Build log available at 'juju_ppc64el.txt'
12:21:53 Build failed for arch 'ppc64el'.
12:21:53 Build complete.
12:21:55 + '[' 0 -ne 0 ']'   # this line was checking the exit status

Additional context

No response

mr-cal commented 1 day ago

Hi @barrettj12,

This behavior should be fixed in snapcraft 8 via https://github.com/canonical/snapcraft/issues/4783