Job artefacts not available on error
To help us investigate test failures we are want to the have the server log made available as an artefact, but from what we can see artefacts are only available on successful builds.
I did look in the docs ( https://docs.gitlab.com/ee/ci/pipelines/job_artifacts.html ), but couldn't see any indicating whether this is a known limitation or at least whether it should work.
Doing an ls -l after the script confirms the file is there following the build.
For now we have worked around this issue by 'cat'ing the logs/main.log file, which is not really ideal.
Our .gitlab-ci.yml file:
image: node:10.16.3
cache:
key: "$CI_BUILD_REF_NAME"
paths:
- node_modules/
services:
- mongo
stages:
- tests
- deploy
before_script:
# deal with private key
- "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
- eval $(ssh-agent -s)
# - echo "$SSH_PRIVATE_KEY"
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
# deal with host key
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- apt-get update
- apt-get install -y rsync
- apt-get install -y jq
- apt-get install -y mongodb-clients
after_script:
- echo $PWD
- env
- ls -l logs/
- cat logs/main.log
all_tests:
stage: tests
variables:
ENV: devci
NODE_ENV: "test"
script:
- export MONGODB_URL=mongodb://mongo:27017/fanmetrix-test
- npm install
- npm run lint
- npm run build
- npm run test-ci
- ls -l
- ls -l *
artifacts:
paths:
- logs/main.log
deploy_dev:
stage: deploy
only:
- master
script:
- npm install
# - scripts/generate-appinfo.sh "$CI_COMMIT_REF_NAME" "$CI_COMMIT_SHA" src/appinfo.json
- npm run build
- ./scripts/deploy.sh dev