Hi folks,
I want to use Gitlab Kubernetes Executor to perform operations on node js with different versions, Gcloud, docker and kubectl.
Everything works perfect with shell executor as the virtual machine(gitab-runners) have all the required softwares installed before then register them to gitlab server.
Can you suggest a proper gitab.ci.yaml “before script” which has all these dependencies installed?
I am using the following GitLab CI/CD pipeline YAMl file.
My goal is to get nvm,gcloud,kubectl preinstalled to gitlab executor pod so I can directly use “npm install’, ‘nvm use 14’, ‘nvm use 16’ command inside “before script” so the build and deploy stage can directly start doing their job.
image: docker:git
variables:
DOCKER_HOST: tcp://docker-dind:2375/
DOCKER_TLS_CERTDIR: ""
VERSION: $CI_PIPELINE_ID
IMAGE_TAG: $CI_COMMIT_REF_NAME-$CI_PIPELINE_ID
IMAGE_NAME: $CI_PROJECT_NAME
GIT_SUBMODULE_STRATEGY: recursive
DOCKER_DRIVER: overlay
services:
- docker:19.03.12-dind
stages:
- test stage
- Build Image
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .npm/
- node_modules
#before_script:
#Can you suggest a proper gitab.ci.yaml “before script” which has all these dependencies installed?
test-stage:
stage: test stage
image: google/cloud-sdk
script:
- echo "$test_DEV" > dev_key.json
- gcloud auth activate-service-account --project $PROJECT_ID_DEV --key-file=dev_key.json
- gcloud auth configure-docker
- docker pull gcr.io/test-dev/test-base:v2
only:
#- gitlab-ci-test
- gitlab-runner-k8s
tags:
- test-runner
dev-build:
stage: Build Image
image: google/cloud-sdk
script:
- echo "$test_DEV" > dev_key.json
- gcloud auth activate-service-account --project $PROJECT_ID_DEV --key-file=dev_key.json
- gcloud auth configure-docker
- echo Building the Docker image...
- docker build -t gcr.io/$PROJECT_ID_DEV/$IMAGE_NAME:$IMAGE_TAG --file Dockerfile.dev .
- docker push gcr.io/$PROJECT_ID_DEV/$IMAGE_NAME:$IMAGE_TAG
only:
#- gitlab-ci-test
- gitlab-runner-k8s
#- /^develop-[a-zA-Z0-9]+(?:.[a-zA-Z0-9]+)+$/
#- /^feature\/[a-zA-Z0-9]+(?:.[a-zA-Z0-9]+)+$/
tags:
- test-runner