Gitlab-ci stage image not pulled - gitlab

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.

Related

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 cannot run `docker` commands in `docker` executor

This has been driving me nuts as I think I'm exactly following the documentation by GitLab for setting up DIND using socket in GitLab Runner so I can run docker commands in Gitlab CI job. But it keeps giving the following error -
Running with gitlab-runner 14.0.0 (3b6f852e)
on Gitlab-HiddenLayer-Group-Runner GosSpAyH
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: gitlab
Using Kubernetes executor with image docker:19.03.12 ...
Using attach strategy to execute scripts...
Preparing environment
00:07
Waiting for pod gitlab/runner-gosspayh-project-27874308-concurrent-0qkp2h to be running, status is Pending
Waiting for pod gitlab/runner-gosspayh-project-27874308-concurrent-0qkp2h to be running, status is Pending
ContainersNotReady: "containers with unready status: [build helper]"
ContainersNotReady: "containers with unready status: [build helper]"
Running on runner-gosspayh-project-27874308-concurrent-0qkp2h via gitlab-runner-gitlab-runner-6984874897-l9z5z...
Getting source from Git repository
00:02
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/GosSpAyH/0/hiddenlayer/hl-tech-blog/.git/
Created fresh repository.
Checking out c48b6257 as master...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:00
$ docker info
Client:
Debug Mode: false
Server:
ERROR: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
errors pretty printing info
Cleaning up file based variables
00:01
ERROR: Job failed: command terminated with exit code 1
Here is my toml configuration in values.yaml for GitLab Runner installation in my private Kubernetes cluster.
config: |
[[runners]]
url = "https://gitlab.com/"
executor = "docker"
privileged = true
[runners.docker]
tls_verify = false
image = "docker:19.03.12"
privileged = true
disable_cache = false
volumes = ["/var/run/docker.sock:/var/run/docker.sock", "/cache"]
[runners.cache]
Insecure = false
and my .gitlab-ci.yml is the following -
image: docker:19.03.12
variables:
DOCKER_DRIVER: overlay2
before_script:
- docker info
- echo "$CI_REGISTRY_USER | $CI_REGISTRY_PASSWORD | $CI_REGISTRY"
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build:
stage: build
# Default branch leaves tag empty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug)
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" -f deploy/Dockerfile .
- docker push "$CI_REGISTRY_IMAGE${tag}"
Note: I'm intentionally leaving the docker-dind service from the .gitlab-ci.yaml file because the documentation says it is not needed.
Additional Information:
Kubernetes Version: 1.20
Gitlab Runner Version: 14.0.0
Running docker commands in CIs is a pretty common workflow and I'm starting to think if it's this difficult to setup, I may as well go back to old ways with using Jenkins.
See if upgrading to GitLab 14.3 (September 2021) would help:
Support for Kubernetes 1.20
In GitLab 14.3, we added support to Kubernetes version 1.20.
GitLab users can benefit from having recent cluster versions in many features, such as the GitLab Kubernetes Agent, Auto DevOps and Cluster Management Project.
You can find the list of supported versions and related timelines in our documentation.
See Documentation and Epic.

Gitlab CloudFormation Integration Pipeline

Description: Attempting to create a simple pipeline to create a cloudformation stack in an aws account.
Looks like its failing to find a script referenced in the documentation below, but I thought cloudformation cli commands were now supported in gitlab 13.9?
Gitlab Version:13.9
CI/CD variables setup:
See required ones here.
https://docs.gitlab.com/ee/ci/cloud_deployment/
gitlab yaml file
variables:
REGION: us-east-2
CI_AWS_CF_STACK_NAME: 'gitlabTestStack'
CI_AWS_CF_CREATE_STACK_FILE: 'aws/aws-test-stack.yaml'
deploy:
stage: deploy
image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest
script:
- gl-cloudprovision create-stack
Output
on PDOCK009-Runner-TestAutomation6 UrKKxyCW
Preparing the "docker" executor
Using Docker executor with image registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest ...
Pulling docker image registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest ...
Using docker image sha256:a39347bds862894f38dabf38f1fddfa0avbc1dc3070ca12400fd0a8d33e7178 for registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest ...
Preparing environment
Running on runner-urkkxycw-project-1427-concurrent-0 via 9cdf65ce059d...
Getting source from Git repository
00:01
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/jackoneill/aws-deploy/.git/
Created fresh repository.
From <URL>
* [new ref] fbf7a9b966f0be1e2db8fbf7a983c02c90ed8saxc2323x -> refs/pipelines/65421
* [new branch] master -> origin/master
Checking out fbf7a9 master...
Skipping Git submodules setup
Restoring cache
Downloading artifacts
00:02
Running before_script and script
00:02
$ gl-cloudprovision create-stack
/usr/bin/bash: line 103: gl-cloudprovision: command not found
Running after_script
Uploading artifacts for failed job
00:02
ERROR: Job failed: exit code 1
Looks like you need to change image to
image: 'registry.gitlab.com/gitlab-org/cloud-deploy/aws-cloudformation:latest'
and script from
- gl-cloudprovision create-stack
to
- gl-cloudformation create-stack

how to troubleshoot the error of Job Failed in Gitlab after running the pipline

Pipline created
stages:
- test
postman_test:
stage: test
image: postman/newman_alpine33
script:
- newman --version
The Response Received
Running with gitlab-runner 13.5.0-rc2 (71c90c86) on
docker-auto-scale 72989761 Preparing the "docker+machine" executor
00:18 Using Docker executor with image postman/newman_alpine33 ...
Pulling docker image postman/newman_alpine33 ... Using docker image
sha256:5cf77cf6f69fea69952c84d804c6dee67bc7c2b66d2962769dfb99ebbd69dedb
for postman/newman_alpine33 with digest
postman/newman_alpine33#sha256:7cd459dc2e9dd8a743548c4f8080f2c38c4e7b7163a0d533ecc3c8099b93b6d9
... Preparing environment 00:04 Running on
runner-72989761-project-21805329-concurrent-0 via
runner-72989761-srm-1602779557-742dd19f... Getting source from Git
repository 00:01 $ eval "$CI_PRE_CLONE_SCRIPT" Fetching changes with
git depth set to 50... Initialized empty Git repository in
/builds/aylin2/project-test/.git/ Created fresh repository. Checking
out fb728cf0 as master... Skipping Git submodules setup Executing
"step_script" stage of the job script 00:02 error: unknown option '-c'
Cleaning up file based variables 00:00 ERROR: Job failed: exit code 1

GitLab CI Pipeline on specific branch composer: command not found

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.

Resources