I have two steps. In both steps I am trying to access a file which does not exist. Both steps should fail, but one succeeded. The workaround is to use script: |- syntax.
kind: pipeline
spec:
stages:
- name: build
spec:
platform:
arch: amd64
os: linux
steps:
- spec:
container:
image: alpine:3
script:
- echo hi
- cat /random-file
type: run
name: itworks
- spec:
container:
image: alpine:3
script:
- cat /random-file
type: run
name: itfails
type: ci
version: 1
Output:
clone
Cloning with 0 retries Initialized empty Git repository in /gitness/.git/ + git fetch origin +refs/heads/main: From http://host.docker.internal:3000/git/Test/TestRepo * branch main -> FETCH_HEAD * [new branch] main -> origin/main + git checkout a6d70fb2f91881478ee2a11a42d2c2cd4c790609 -b main Switched to a new branch 'main'
itworks
+ echo hi hi
itfails
+ cat /random-file cat: can't open '/random-file': No such file or directory
I have two steps. In both steps I am trying to access a file which does not exist. Both steps should fail, but one succeeded. The workaround is to use
script: |-
syntax.Output: