title: Gitlab CI - Publish Failed Test Results to Pages
body: <p>I'm creating a simple java project using <code>Gradle</code> which generates a test report (i.e. BDD Cucumber, JUnit, etc.). This project is deployed to <code>Gitlab</code> where the project is built as part of the <code>Gitlab CI</code> process.</p>
  
  <p>My <code>JUnit</code> reports are generated in the folder <code>build/reports/tests/test/</code> relative to the project path (as an <code>index.html</code> and some <code>CSS</code> files, etc.).</p>
  
  <p>How do I configure my <code>.gitlab-ci.yml</code> to publish the content of <code>build/reports/tests/test/</code> to the Gitlab Pages <strong>even after my test cases fail</strong>?</p>
  
  <p>This is what I have in my <code>.gitlab-ci.yml</code>: (My repo can be found <a href="https://gitlab.com/mohammad.mnajar/gitlab-ci-project" rel="nofollow noreferrer">HERE</a>)</p>
  
  <p>Version 1: Doesn't publish anything to pages</p>
  
  <pre><code>image: java:8-jdk
  
  stages:
    - test
  
  before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
  
  test:
    stage: test
    script:
      - mkdir public
      - ./gradlew test
  
    artifacts:
      paths:
        - build/reports/tests/test/
    only:
    - master
  
  after_script:
    - mv build/reports/tests/test/* public
  </code></pre>
  
  <hr>
  
  <p>Version 2: Doesn't execute the <code>deploy</code> stage since <code>test</code> has failed.</p>
  
  <pre><code>image: java:8-jdk
  
  stages:
    - test
    - deploy
  
  before_script:
    - export GRADLE_USER_HOME=`pwd`/.gradle
  
  test:
    stage: test
    script:
      - ./gradlew test
  
    artifacts:
      paths:
        - build/reports/tests/test/
  
   pages:
     stage: deploy
     dependencies:
       - test
     script:
     - mkdir public
     - mv build/reports/tests/test/* public
     artifacts:
       paths:
        - public
  
    only:
    - master
  </code></pre>