GitLab CI Pipeline on specific branch composer: command not found - gitlab

I'm trying to implement GitLab CI Pipelines to build and deploy an app.
In our project we have two branches: master and others.
For a particular branch(eg:p-01-sprint-04), I want to run a Pipeline in order to build the application and deploy the build on a test environment.
The build failed during execution.
This is how my .gitlab-ci.yml looks like:
stages:
- test
unit_test:
stage: test
script:
- composer install
- php artisan migrate
- php artisan db:seed
- composer require laravel/passport
- php artisan passport:client --personal
- php artisan storage:link
- php artisan serve
The build failed with these errors :
Running with gitlab-runner 11.8.0 (4745a6f3)
on gitlab-runner-gitlab-runner-64c48b5865-wx6wl BS2DZ3GP
Using Kubernetes namespace: gitlab
Using Kubernetes executor with image ubuntu:16.04 ...
Waiting for pod gitlab/runner-bs2dz3gp-project-924-concurrent-0tzq4t to be running, status is Pending
Waiting for pod gitlab/runner-bs2dz3gp-project-924-concurrent-0tzq4t to be running, status is Pending
Running on runner-bs2dz3gp-project-924-concurrent-0tzq4t via gitlab-runner-gitlab-runner-64c48b5865-wx6wl...
Cloning into '/mk2/billeterie/bo'...
Cloning repository...
Checking out 841a7daf as p-01-sprint-04...
Skipping Git submodules setup
$ composer install
/bin/bash: line 72: composer: command not found
ERROR: Job failed: command terminated with exit code 1

Log shows you use ubuntu:16.04 with kubernetesexecutor :
Using Kubernetes executor with image ubuntu:16.04 ...
composer is not installed in ubuntu:16.04 docker image.
Use composer image instead which provide phpand composer binaries.

Related

gitlab pipeline job failed when using gitlab-runner start, but success when using gitlab-runner run

the .gitlab-ci.yml file is
stages: # List of stages for jobs, and their order of execution
- build
build-job: # This job runs in the build stage, which runs first.
stage: build
script:
- echo "hello world"
tags:
- cpu
I run the gitlab-runner (10.5.0) on a specific runner (ubuntu 18.04), it work successfully when I use run command:
sudo gitlab-runner run
but failed when I use start (or restart)
sudo gitlab-runner start
No trace info on either mode.

Gitlab-ci stage image not pulled

I'm facing an strange behaviour.
Below my .gitlab-ci.yml
image: node:latest
stages:
- release
release:
image: registry.gitlab.com/gitlab-org/release-cli
stage: release
script:
- release-cli create --name release-branch-$CI_JOB_ID --description "desc" --tag-name job-$CI_JOB_ID --ref $CI_COMMIT_SHA
The pipeline is finishing with the following error:
Running with gitlab-runner 14.6.0 (5316d4ac)
on shell-runner gmyChsa1
Preparing the "shell" executor
Using Shell executor...
Preparing environment
Running on myserver.com...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /home/gitlab-runner/builds/gmyChsa1/0/kleyson-sr/changelog-test/.git/
Checking out 21ab4cac as main...
Removing desc.md
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ release-cli create --name release-branch-$CI_JOB_ID --description "desc" --tag-name job-$CI_JOB_ID --ref $CI_COMMIT_SHA
bash: line 137: release-cli: command not found
Cleaning up project directory and file based variables
ERROR: Job failed: exit status 1
The stage release is not pulling and using the release-cli image instead of the global node:latest image.
How can I fix that ?
PS.: Running the pipeline in a local gitlab server.
Running with gitlab-runner 14.6.0 (5316d4ac)
on shell-runner gmyChsa1
Your job is using a GitLab runner configured with the shell executor. This means that the image: directive is ignored entirely.
To use an image: you will need to use a runner configured with a docker/kubernetes/custom executor that supports running jobs in an image.

GitLab CI Timeout with Kaniko and EKS

I am trying to follow the GitLab example code for using kaniko as outlined here. The only thing I have changed is that I am using the v1.7.0-debug tag instead of simply debug.
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:v1.7.0-debug
entrypoint: [""]
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
My build job is stalling out at the following line:
Running with gitlab-runner 14.4.0 (4b9e985a)
on gitlab-runner-gitlab-runner-84d476ff5c-mkt4s HMty8QBu
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: gitlab-runner
Using Kubernetes executor with image gcr.io/kaniko-project/executor:v1.7.0-debug ...
Using attach strategy to execute scripts...
Preparing environment
00:03
Waiting for pod gitlab-runner/runner-hmty8qbu-project-31186441-concurrent-0bbt8x to be running, status is Pending
Running on runner-hmty8qbu-project-31186441-concurrent-0bbt8x via gitlab-runner-gitlab-runner-84d476ff5c-mkt4s...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/...
Created fresh repository.
Checking out 4d05d22b as ci...
Skipping Git submodules setup
Executing "step_script" stage of the job script
It just stops at Executing "step_script" and never moves on. I've researched all over and read through as much documentation as I can find but am unable to troubleshoot this issue.
Setup
Amazon EKS version 1.21
GitLab Runner Helm Chart version 0.34.0
kaniko executor image v1.7.0-debug
This ended up being an issue with how the Kubernetes runner itself was configured inside of the runner configuration toml. The default container image we were using for our runners required a modification to the PATH environment variable so we were using the environment configuration setting to do this as outlined here. It seems that this PATH variable did not include the busybox shell defined in the kaniko debug image. We have since moved that PATH change inside our Docker image where it should've been in the first place and things are working as expected.

Gitlab-runner permissions

Trying out gitlab and trying to build a simple create-react-app project. However, I'm having issues with the gitlab-runner. I'm running gitlab on an EC2 instance using the AMI from gitlab that's in the amazon marketplace.
by yml is really basic.
build-site:
image: node:9
stage: build
script:
- npm install
- npm run build
artifacts:
expire_in: 1 week
paths:
- build
However the output I get in the gitlab web UI is
Running with gitlab-runner 10.1.0 (c1ecf97f)
on runner-1 (9fc6bc1c)
Using Shell executor...
Running on ip-10-214-239-156...
Fetching changes...
warning: failed to remove builds/0/project-0.tmp/git-template/config
warning: failed to remove builds/0/project-0/.istanbul.yml
warning: failed to remove builds/0/project-0/yarn.lock
warning: failed to remove builds/0/project-0/src/Root.js
warning: failed to remove builds/0/project-0/src/utils/common.js
and the output I get when running sudo gitlab-runner --debug exec shell build-site when ssh'ed into the ec2 machine
ERROR: Job failed: exit status 1
FATAL: exit status 1
had to add user gitlab-runner to docker group
usermod -aG docker gitlab-runner
seems to have done the trick

build and push docker images with GitLab CI

I would like to build and push docker images to my local nexus repo with GitLab CI
This is my current CI file:
image: docker:latest
services:
- docker:dind
before_script:
- docker info
- docker login -u some_user -p nexus-rfit some_host
stages:
- build
build-deploy-ubuntu-image:
stage: build
script:
- docker build -t some_host/dev-image:ubuntu ./ubuntu/
- docker push some_host/dev-image:ubuntu
only:
- master
when: manual
I also have a job for an alpine docker image, but when I want to run any of it it's failing with the following error:
Checking out 13102ac4 as master...
Skipping Git submodules setup
$ docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
ERROR: Job failed: exit code 1
So technically the docker daemon in the image isn't running, but I have no idea why.
GitLab folks have a reference on their docs about using docker-build inside docker-based jobs: https://docs.gitlab.com/ce/ci/docker/using_docker_build.html#use-docker-in-docker-executor. Since you seem to have everything in place (i.e. the right image for the job and the additional docker:dind service), it's most likely a runner-config issue.
If you look at the second step in the docs:
Register GitLab Runner from the command line to use docker and privileged mode:
[...]
Notice that it's using the privileged mode to start the build and service containers. If you want to use docker-in-docker mode, you always have to use privileged = true in your Docker containers.
Probably you're using a runner that was not configured in privileged mode and hence can't properly run the docker daemon inside. You can directly edit the /etc/gitlab-runner/config.toml on your registered runner to add that option.
(Also, read on the section on the docs for some more info about the performance related to the storage driver you choose/your runner supports when using dind)

Resources