Running commands that normally exit with code 1

How do I add commands to one of my pipeline steps, that are expected to return an exit code of 1?

In one of my pipelines I have to generate a diff between two directories. I do this with the ubiquitous tool diff. Now I have problems with the exit code definition of diff:

From the man page:

Exit status is 0 if inputs are the same, 1 if different, 2 if trouble.

I tried the following, but the step is still failing:

kind: pipeline
name: default

steps:
- name: build
  image: debian:stretch
  commands:
  - export LC_ALL=C.UTF-8
  - export LANG=C.UTF-8
  - (diff -Naur a b > 1000_changed_dtb_files.patch) ; true
- name: notify
  image: drillster/drone-email
  settings:
    host:
      from_secret: SMTP_HOST
    username:
      from_secret: SMTP_USER
    password:
      from_secret: SMTP_PASS
    from:
      from_secret: SMTP_FROM
    recipients: [ [email protected], [email protected] ]
    attachment: 1000_changed_dtb_files.patch
  when:
    status: [ changed, failure ]

You can adjust your shell syntax. this worked for me:

#!/bin/sh
set -e

echo foo > a
echo bar > b
-(diff -Naur a b > c.patch); true
+(diff -Naur a b > c.patch) | true
echo done

before:

$ sh test.sh
$ echo $?
1

after:

$ sh test.sh
done
$ echo $?
0

Sorry, I forgot to reply.

Thanks, this worked!