Skip to content

Need to continue with CI script when xcodebuild test fails

Summary

Hi Guys! I am running a test build for my XCode project in a runner, and I am having the following behaviour. First of all, this is my test build in the .gitlab-ci.yml file:

test_build:
  stage: test
  tags:
  - macos
  inherit:
    default: false
  needs:
  - job: build_job
    artifacts: true
  script:
  - echo testing build
  - xcodebuild test -scheme ProjectTests -resultBundlePath TestResults -destination 'platform=iOS Simulator,name=iPhone 11,OS=13.7'
  - echo get report
  - xchtmlreport -r TestResults
  allow_failure: true
  dependencies:
    - build_job
  artifacts:
    when: always
    paths:
      - index.html
    reports:
      junit: index.html

The problem that I am having is that when xcodebuild test command fails because of a failing test, the script won’t continue and therefore, xchtmlreport won’t be executed. I already tried writing both commands in the same line separated by a semicolon, so xchtmlreport should be executed even if xcodebuild fails, but it didn’t work either. I need that xchtmlreport command runs no matter the result of xcodebuild test because obviously I need the report for both the error and the success cases.

Steps to reproduce

Run .gitlab-ci.yml file and the command after xcodebuild test won’t run if a test fails.

Example Project

What is the current bug behavior?

The command after xcodebuild test won’t run if a test fails.

What is the expected correct behavior?

I need that xchtmlreport command runs no matter the result of xcodebuild test because I need the report for both the error and the success cases.

Relevant logs and/or screenshots

Screenshot_2020-10-28_at_11.46.03

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes