Where on GitLab.com do I find the pipeline error logs? - gitlab

I've been working on getting a .gitlab-ci.yml pipeline to work but cannot find where the logs go.
GitLab.com message tells me
npm ERR! /root/.npm/_logs/2022-05-06T09_39_43_597Z-debug.log
I do not see this folder created on my project within GitLab.com so where and how do I get to the log?
After 51 iterations I have made a little bit of progress. 1st time seeing Green.

You could use artifacts to keep the log file, if the job fails. For example:
my job:
...
artifacts:
paths:
- "*.log"
when: on_failure
I'm not sure the paths pattern is correct. So, perhaps, it is neccessary to use **/*.log instead of *.log. But I hope, the idea is clear.

That can be seen by adding debug logging to your .gitlab-ci.yml file.Once you add it ,run the job again and you can get a detailed log

Related

Gitlab output log display runtime values instead of variables

Is it possible to get GitLab to report out what it's actually running in the output log. For example, the following .gitlab-ci.yml
variables:
MAVEN_CLI_OPTS: >-
-s $CI_PROJECT_DIR/.m2/settings.xml
--batch-mode
--errors
--fail-at-end
--show-version
-DinstallAtEnd=true
-DdeployAtEnd=true
compile-test-package:
stage: package
script:
- mvn ${MAVEN_CLI_OPTS} package
The run log then shows this
...
mvn ${MAVEN_CLI_OPTS} package
...
But I really would like it to give the specific details like
...
mvn -s path/to/my/project/.m2/settings.xml --batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true package
...
The best I've learned on this is that GitLab doesn't have a way to report the full details of what its executing. As Michael Delgado mentioned, putting an echo in to output will give you a method to do this. However use this with cation cause protected values could be exposed using this method.
I'm still struggling with variable replacement but at least now I can see what GitLab is replacing and not.

Included file does not have a valid YAML syntax

I am including a remote .gitlab-ci.yml file
variables:
ENTITY_NAME: $CI_PROJECT_TITLE
include:
remote: 'https://gitlab.com/paulblart/paul_test/-/main/.gitlab-ci.yml'
but checking for it YAML syntax in CI Lint GUI its saying
Included file 'https://gitlab.com/paulblart/paul_test/-/main/.gitlab-ci.yml' does not have valid YAML syntax!
But upon checking the syntax of .gitlab-ci.yml of the remote file its valid. I am not sure whats going on.
I saw a different version of problem in my case, I was trying to set CI/CD configuration file pointing to a different project with relatively longer name of a valid yaml file. I checked the linting, file was yaml but error thrown while attempting to run the pipeline was:
Included file .gitlab-ci-a-very-long-gilabci-file.yml#group/subgroup/pipeline-project does not have YAML extension!
Shortening the name solved it, Gitlab can improve the error messages.
Just adding as I didn't find it on Stackoverflow.
I have workaround for this issue
include:
- project: "my-project-with-yml/project-name"
ref: master
file: "/yml/.gitlab-ci.yaml"
rules: ## Optional, to show the support to **rules**
- if: $variable == "condition "
I was also facing the issue with YAML Error, even though the lint was green.
I had this error come up when I was trying to access a gitlab group which wasn't public, so I didn't have rights to look at the file.
Very uninformative error in that case.

Gitlab runner does not always update environment

I have a gitlab job that does not seem to update the repository before being run. Sometimes it leaves some files in their old states and run the script... Any idea ?
For instance when I have a
packagePython:
stage: package
script:
- .\scripts\PackagePython.ps1
tags:
- myServer
cache:
paths:
- .\python\cache\
only:
changes:
- python/**/*
I finally managed to understand what was happening :
I realised that the gitlab-runner did not use exactly the same path for each run on my server, and my script assumed that it did... So I ended up pointing on a build made on the wrong path.
I guess if you think that it is not updating the repository (like I did) make sure you are not referencing hardcoded path/package in your scripts that could refer to previous versions !

Gitlab CI variables returns empty string?

It's been 2 days since one of my project' build starts failing on Gitlab CI. The main error was E_MISSING_APP_KEY and when I check another variable just by echoing $HOST and $PORT from my .gitlab-ci.yml config, like this
tests:
script:
- echo "${HOST} ${PORT}"
- node -e "console.log(process.env.HOST, process.env.PORT)"
- node_modules/.bin/nyc node ace test -t 0
I got nothing.
The build was failed because it can't read my environment variable that I set on its CI Settings.
Anyone experiencing same issue? & how to solve this?
Update:
I'm trying to create new project with only containing .gitlab-ci.yml file here and it's seems working just fine
But why the world it's still failing on my main project?
For anyone else having a similar problem:
check your variable, if it is protected your branch has to be protected as well or remove the protected option on your variable
The issue is solved by delete all of my variables I've had & set them back from the CI Setting. And the build pipeline is running without any errors. (except the actual testing is still failed, lol)
Honestly, I'm still wondering why this could happened? and hopefully no one will experiencing same kind of issue like me here..

GitLab Pages deployment step fails after successfull build

I am trying to host a reveal.js presentation via gitlab pages. The repository can be found here: https://gitlab.com/JanGregor/demo-slides
My .gitlab-ci.yml is fairly simple:
image: node:4.2.2
pages:
cache:
paths:
- node_modules/
script:
- npm install
- node_modules/.bin/gulp
artifacts:
paths:
- build
only:
- master
After a commit to master though, something goes wrong. The pages task itself is executed and runs just fine. It even shows in the logs that my build directory has been scanned and that the artefacts have been found.
Oddly, the subsequent pages:deploy task fails. It only says :
pages failed to extract
Any help would be greatly appreciated, since I have no clue where to look to next. The documentation itself isn't really helpful when trying to implement an deployment flow with npm.
Thanks in advance folks !
Apparently a page can only be published from a folder in under the artifacts that is called "public".
From the GitLab Pages documentation:
To make use of GitLab Pages, the contents of .gitlab-ci.yml must follow the rules below:
A special job named pages must be defined
Any static content which will be served by GitLab Pages must be placed under a public/ directory
artifacts with a path to the public/ directory must be defined
Also mentioned (somewhat tangentially) in the "GitLab Pages from A to Z" guide:
... and GitLab Pages will only consider files in a directory called public.

Resources