Gitlab

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
     *.                  *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.

_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ \`/ __ \\
/ /_/ / / /_/ /___/ /_/ / /_/ /
\____/_/\__/_____/\__,_/_.___/

Define gitlab-ci yaml aliases to reuse blocks between pipes

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
stages:
- test
- analysis
- deploy

## Define yaml template, `&before-script` is the anchor
.before: &before-script
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- yarn

test:
stage: test
image: node:8.9
coverage: '/All files([^|]*\|){4}[^\d]+([\d|\.]+)/'
## Including yaml template
<<: *before-script
script:
- yarn test --coverage --verbose

deploy:
stage: deploy
image: ciricihq/node:lts-oc
only:
- tags
## Including yaml template
<<: *before-script
script:
- yarn run build
- "NODE_ENV=production oc publish . --username lefunker --password $REGISTRY_PASSWORD"

Build docker image and push it to gitlab.com repository

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
stages:
- test
- build

variables:
DOCKER_DRIVER: overlay

test:
stage: test
image: node
script:
- yarn
- yarn test

docker-image:
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker build -t registry.gitlab.com/gtrias/photowall:latest .
- docker push registry.gitlab.com/gtrias/photowall:latest

Define an image from a private Container Registry

Manually run gitlab-runner task

1
2
# In the project root with .gitlab-ci.yml file
gitlab-runner exec docker <name-of-task>

Lint your gitlab-ci.yml from CLI

Deploy frontend projects

Comments

⬆︎TOP