Reputation: 21
I want to use this Docker image:
https://cloud.docker.com/u/steevanb/repository/docker/steevanb/php-code-sniffs
From this Dockerfile:
https://github.com/steevanb/docker-php-code-sniffs/blob/master/Dockerfile
Locally, i use it like that:
#!/bin/bash
set -e
readonly PROJECT_DIR=$(realpath $(dirname $(realpath $0))/..)
docker run \
--rm \
-e PHPCS_PARAMETERS="--warning-severity=0 --ignore=/var/phpcs/var,/var/phpcs/vendor/" \
-e PHPCS_BOOTSTRAP=/var/phpcs.bootstrap.php \
-v ${PROJECT_DIR}:/var/phpcs:ro \
-v ${PROJECT_DIR}/phpcs.bootstrap.php:/var/phpcs.bootstrap.php:ro \
steevanb/php-code-sniffs:2.0.9
I don't understand how i can use it in Gitlab CI, with same parameters?
I've tried some things, like that:
phpcs:
image:
name: steevanb/php-code-sniffs:2.0.9
entrypoint: ["/var/steevanb/php-code-sniffs/vendor/bin/phpcs", "$CI_PROJECT_DIR/project/user/src"]
# don't need it, everything is done by overloading entrypoint
script: echo $CI_PROJECT_DIR
But i have this error, seems $CI_PROJECT_DIR is not replaced with the expected value:
RROR: The file "$CI_PROJECT_DIR/project/user/src" does not exist.
Upvotes: 2
Views: 2887
Reputation: 2705
You can pass environment variables using either GitLab Secret Variables (set in the project settings) or by specifying variables in .gitlab-ci.yml
.
See GitLab CI YAML Variables documentation.
For example, in your .gitlab-ci.yml
you may be able to specify:
variables:
PHPCS_PARAMETERS: --warning-severity=0 --ignore=/var/phpcs/var,/var/phpcs/vendor/
PHPCS_BOOTSTRAP: PHPCS_BOOTSTRAP=/var/phpcs.bootstrap.php
image: steevanb/php-code-sniffs:2.0.9
your_job:
script:
- your_script
In this example, the variables and image are set globally. You can also set both of these within each job rather than globally.
Upvotes: 0
Reputation: 148
In order to use your own image in default runners, you need to put image
In the beginning of .gitlab-ci.yml
, you should write it like:
image: python:alpine
before_script:
- pip install mkdocs
...
Upvotes: 1
Reputation: 342
If you are using gitlab CI/CD
you can use your image by uploading the images to docker hub.
Steps to produce docker image:
1.compose a Docker file in your local machine.
2.build a docker image using that docker file.
3.name the docker image, create or login to docker hub
4.publish the image to you docker repository.
Reference: click here
Upvotes: 0