title: CI-pipeline ignore any commands that fail in a given step
body: <p>I'm trying to debug a CI pipeline and want to create a custom <code>logger</code> stage that dumps a bunch of information about the environment in which the pipeline is running.</p>
  <p>I tried adding this:</p>
  <pre><code>stages:
      - logger
  
  logger-commands:
      stage: logger
      allow_failure: true
      script:
          - echo 'Examining environment'
          - echo PWD=$(pwd) Using image ${CI_JOB_IMAGE}
          - git --version
          - echo --------------------------------------------------------------------------------
          - env
          - echo --------------------------------------------------------------------------------
          - npm --version
          - node --version
          - echo java -version
          - mvn --version
          - kanico --version
          - echo -------------------------------------------------------------------------------- 
  </code></pre>
  <p>The problem is that the Java command is failing because <code>java</code> isn't installed.  The error says:</p>
  <pre><code>/bin/sh: eval: line 217: java: not found
  </code></pre>
  <p>I know I could remove the line <code>java -version</code>, but I'm trying to come up with a canned logger that I could use in all my CI-Pipelines, so it would include: Java, Maven, Node, npm, python, and whatever else I want to include and I realize that some of those commands will fail because some of the commands are not found.</p>
  <p>Searching for the above solution got me close.</p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/59180675/gitlab-ci-how-to-continue-job-even-when-script-fails">GitLab CI: How to continue job even when script fails</a> - Which did help.   By adding <code>allow_failure: true</code> I found that even if the logger job failed the remaining stages would run (which is desirable).  The answer also suggests a syntax to wrap commands in which is:</li>
  </ul>
  <pre><code>./script_that_fails.sh &gt; /dev/null 2&gt;&amp;1 || FAILED=true
  
  if [ $FAILED ]
      then ./do_something.sh
  fi
  </code></pre>
  <p>So that is helpful, but my question is this.</p>
  <p><strong>Is there anything built into gitlab's CI-pipeline syntax (or bash syntax) that allows all commands in a given step to run even if one command fails?</strong></p>
  <ul>
  <li><a href="https://stackoverflow.com/questions/55708975/is-it-possible-to-allow-for-a-script-in-a-ci-cd-job-to-fail">Is it possible to allow for a script in a CI/CD job to fail?</a> - suggests adding the UNIX bash OR syntax as shown below:</li>
  </ul>
  <pre><code>        - npm --version || echo nmp failed
          - node --version  || echo node failed
          - echo java -version || echo java failed
  </code></pre>
  <p>That is a little cleaner (syntax) but I'm trying to make it simpler.</p>