I'm new on learning Gitlab with community self hosted version, i installed a locally community version on my PC using Docker Compose, i used this file in order to install it:
#Declaramos el servicio que contendra GitLab como 'web' web: #Seleccionamos la imagen de 'Gitlab community edition' image: 'gitlab/gitlab-ce:latest' #En caso de fallas reiniciamos el servidor restart: always #Definimos los puertos de escucha ports: - '8182:8182' - '80:80' - '443:443' - '22:22' #Definimos el 'hostname' debemos verificar primero si se va a ejecutar Local # para ver que direccion IP se va a usar o que DNS se va a usar hostname: '192.168.xx.x' #Declaramos las variables de entorno environment: #Definimos la variable de entorno 'GITLAB_OMNIBUS_CONFIG' con las configuraciones iniciales GITLAB_OMNIBUS_CONFIG: external_url 'http://192.168.xx.x' gitlab_rails['gitlab_shell_ssh_port'] = 2224 #Definimos los volumenes de almacenamiento para persistencia #Notese que se crea una carpeta 'srv' donde se almacenan los datos de 'GitLab' en caso de no existir volumes: - './srv/gitlab/config:/etc/gitlab' - './srv/gitlab/logs:/var/log/gitlab' - './srv/gitlab/data:/var/opt/gitlab' - './srv/var/opt/gitlab/gitlab-rails/shared/artifacts' #Definimos el tamaño en memoria maximo shm_size: '512m'
The installation worked at first, i can create repositories and upload changes to the gitlab installed on my machine, and i'm working with a basic project made on Angular.
But when i try to do CI/CD i have a problem, cosider this file .gitlab-ci.yaml:
#Automatizacion del proyecto con Gitlab CI
#Definimos la imagen
image: node:16.17
#Definimos las etapas
stages:
- install
- test
#Definimos un 'job' la instalacion de dependencias
install-dependencies:
#Definimos que pertenece a la etapa 'install' declara mas arriba
stage: install
#Ejecutamos los comandos de instalacion
script:
- npm install
#Comunicamos con el resto del pipeline de ci
artifacts:
expire_in: 1hr
#Definimos que los artefactos a exportar es 'node_modules'
paths:
- node_modules/
#Definimos un 'cache' para almacenar 'node_moudules' y agilizar los 'builds'
cache:
paths:
- node_modules/
#
allow_failure: true
#
only:
- main # or the name of your main branch
#
tags:
- IntegracionGitLabCI
#Definimos un 'job' para ejecutar los 'tests'
test-apps:
#Definimos que pertenece a la etapa 'test' declara mas arriba
stage: test
#Declaramos las variables de entorno para los 'test'
variables:
CHROME_BIN: google-chrome
#Decimos que depende del 'job' 'install-dependencies'
dependencies:
- install-dependencies
#A continuacion pasamos los comandos para instalar 'chrome'
before_script:
- apt-get update && apt-get install -y apt-transport-https
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
- sh -c 'echo "deb https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
- apt-get update && apt-get install -y google-chrome-stable
#Ejecutamos el comando de ejecucion de los 'tests' (ver 'package.json')
script:
- npm install
- npm run test:ci
#
allow_failure: true
#
only:
- main # or the name of your main branch
#
tags:
- IntegracionGitLabCI
I uploaded the project simultaneously to gitlab.com, registered a runner both in gitlab.com and in my gitlab self hosted into my machine and run my first jobs, in gitlab.com the jobs are finished successfully but in my self hosted machine i have a problem with job install-dependencies one when i upload artifacts, i got this message error:
Created cache
Uploading artifacts for successful job
Uploading artifacts...
node_modules/: found 43727 matching files and directories
WARNING: Uploading artifacts as "archive" to coordinator... POST http://192.168.xx.x/api/v4/jobs/87/artifacts: 500 Internal Server Error id=87 responseStatus=500 Internal Server Error status=500 token=wa9Z9zEN
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "archive" to coordinator... POST http://192.168.xx.x/api/v4/jobs/87/artifacts: 500 Internal Server Error id=87 responseStatus=500 Internal Server Error status=500 token=wa9Z9zEN
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "archive" to coordinator... POST http://192.168.xx.x/api/v4/jobs/87/artifacts: 500 Internal Server Error id=87 responseStatus=500 Internal Server Error status=500 token=wa9Z9zEN
FATAL: invalid argument
ERROR: Job failed: exit code 1
I tried to change the hostname and external_url respectively to these combinations on my docker-compose.yml file:
192.168.xx.xandhttp://192.168.xx.x192.168.xx.x:8182andhttp://192.168.xx.x:8182192.168.xx.xandhttp://192.168.xx.x:8182192.168.xx.x:8080andhttp://192.168.xx.x:8080192.168.xx.xandhttp://192.168.xx.x:8080localhostandhttp://localhost:8182localhostandhttp://localhostlocalhost:8080andhttp://localhost:8080localhostandhttp://localhost:8080localhost:8182andhttp://localhost:8182
And registered the repectively runners for each one, and i get the same error, infact in some cases the url for artifacts changes in wrong way.
I also increased the Maximum artifacts size on my configurations.
If i quit the "artifact" parts seems to work, but i don't know why it is working on GitLab.com instead of my local machine and if the artifacts is disabled on community edition or something.
The strange thing is that testing job is working fine and in fact i integrated the local GitLab with Sonarqube and other tools successfully
Thank you for your help