Commit 1ffd9c8e authored by Emeric Verschuur's avatar Emeric Verschuur

Remove ci-job-wrapper jobs and update the documentation

parent b3c03a1e
job-with-volumes:
image: ubuntu:16.04
volumes_from_images:
- registry.gitlab.com/ercom/cijw4gitlab:volume-sample
job-test-services-ext:
image: postgres:9.4
volumes_from_images:
- registry.gitlab.com/ercom/cijw4gitlab:volume-sample
docker_run_args:
network: bridge
services:
- mysql
- name: postgres:9.4
alias: db-postgres
wait_before_run_job: 1
entrypoint: ["docker-entrypoint.sh"]
command: ["postgres"]
docker_run_args:
privileged: true
network: bridge
......@@ -2,7 +2,7 @@
image: ubuntu:16.04
variables:
GLOBALJOBVAR: "blobal variable"
GLOBALJOBVAR: "global variable"
after_script:
- echo "job ${CI_JOB_NAME} end"
......@@ -34,23 +34,12 @@ job-advanced:
- echo ${JOBADVAR}
- tools/gitlab-ci/run.sh
job-with-volumes:
image: registry.gitlab.com/ercom/cijw4gitlab:2.0.1
stage: build
only:
- /^$/
script:
- test -f /path/to/my/volume/content
- 'echo "/path/to/my/volume/content file content: $(cat /path/to/my/volume/content)"'
job-test-services-mysql:
stage: build
variables:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
CITBX_WAIT_FOR_SERVICE_START: 10
only:
- /^$/
image: mysql
services:
- mysql
......@@ -63,8 +52,6 @@ job-test-services-postgres:
stage: build
variables:
CITBX_WAIT_FOR_SERVICE_START: 10
only:
- /^$/
image: postgres:9.4
services:
- name: postgres:9.4
......@@ -75,16 +62,3 @@ job-test-services-postgres:
- test
script:
- psql -h db-postgres -U postgres -c 'select version();'
job-test-services-ext:
image: registry.gitlab.com/ercom/cijw4gitlab:2.0.1
stage: build
variables:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
only:
- /^$/
tags:
- test
script:
- "true"
......@@ -7,46 +7,45 @@ This toolbox can be used to
## Table of contents
* [The project](#the-project)
* [Use case: Standard Gitlab-CI pipeline job](#use-case-standard-gitlab-ci-pipeline-job)
* [Run a specific job locally](#run-a-specific-job-locally)
+ [Fist solution: using gitlab-runner tool](#fist-solution-using-gitlab-runner-tool)
+ [Other solution: Use run.sh tool](#other-solution-use-runsh-tool)
* [Write a job or a module script using CI toolbox](#write-a-job-or-a-module-script-using-ci-toolbox)
+ [Write a job](#write-a-job)
+ [Write a module](#write-a-module)
+ [Useful function list](#useful-function-list)
* [Job examples](#job-examples)
+ [job-minimal](#job-minimal)
+ [job-with-before-after-script](#job-with-before-after-script)
+ [job-advanced](#job-advanced)
+ [job-with-volumes](#job-with-volumes)
* [The project](#the-project)
* [Use case: Standard Gitlab-CI pipeline job](#use-case-standard-gitlab-ci-pipeline-job)
* [Run a specific job locally](#run-a-specific-job-locally)
* [Fist solution: using gitlab-runner tool](#fist-solution-using-gitlab-runner-tool)
* [Other solution: Use ci-toolbox command](#other-solution-use-ci-toolbox-command)
* [Write a job or a module script using CI toolbox](#write-a-job-or-a-module-script-using-ci-toolbox)
* [Write a job](#write-a-job)
* [Write a module](#write-a-module)
* [Useful function list](#useful-function-list)
* [Job examples](#job-examples)
* [job-minimal](#job-minimal)
* [job-with-before-after-script](#job-with-before-after-script)
* [job-advanced](#job-advanced)
* [job-test-services-mysql](#job-test-services-mysql)
* [job-test-services-postgres](#job-test-services-postgres)
## The project
The citbx4gitlab project tree
A citbx4gitlab integration example into a project tree
```
├── .ci-job-wrapper.yml
├── .git
├── .gitlab-ci.yml
├── doc
├── LICENSE
├── README.md
└── tools
└── gitlab-ci
├── 3rdparty
│ └── bashopts.sh
├── citbx.properties
├── env-setup
│ └── ubuntu.sh
├── modules
│ ├── ccache.sh
└── example.sh
├── run -> run.sh
├── run.d
└── job-advanced.sh
└── run.sh
├── tools
│   └── gitlab-ci
│   ├── 3rdparty
│   │   └── bashopts.sh
│   ├── citbx.properties
│   ├── env-setup
│   │   ├── common.sh
│   │   ├── gentoo.sh
│   │   └── ubuntu.sh
│   ├── modules
│   │   ├── ccache.sh
│   │   ├── dockerimg.sh
│   │   └── example.sh
│   ├── run -> run.sh
│   ├── run.d
│   │   └── job-advanced.sh
│   └── run.sh
```
The minimal element list:
......@@ -55,13 +54,16 @@ The minimal element list:
* ```run.sh```: tool to run Gitlab-CI job on the workstation
* ```bashopts.sh```: dependency required by run.sh
The additional element list:
The recommended additional element list:
* ```run.d```: directory containing job specific functions
* ```modules```: directory containing the modules
* ```env-setup```: directory containing the workstation environment setup script
* ```citbx.properties```: CI toolbox project properties
The advanced additional element list:
* ```run.d```: directory containing job specific functions
* ```modules```: directory containing the modules
## Use case: Standard Gitlab-CI pipeline job
The following schema describe the standard execution of a job called "J" in a Gitlab-CI pipeline
......@@ -88,7 +90,7 @@ In addition you have to:
* Commit the changes to be taken in board by the gitlab-runner
* Add gitlab-runner executor option like ```--docker-image```
### Other solution: Use run.sh tool
### Other solution: Use ci-toolbox command
This tool is able to:
......@@ -101,6 +103,17 @@ Additional advanced run.sh tool functionalities:
* Add ability to run a shell into the suitable job docker environment
* Split job parts in modular format (Job parts, modules, ...)
Usage:
* ```ci-toolbox <command> [arguments...]``` from anywhere in the project directory, ... or:
* ```path/to/run.sh <command> [arguments...]```
The ```ci-toolbox``` command, installed into the system during the ```path/to/run.sh setup```, add the following functionalities:
* This tool can be run anywhere in a project containing the run.sh script
* This tool is like a shortcut to find and run run.sh script without have to specify the absolute/relative path
* This tool add BASH auto completion support
Know limitations:
* Only applicable for docker and shell executor
......@@ -230,25 +243,47 @@ Job run:
![Job advanced](doc/TestCaseJobAvanced.png)
### job-with-volumes
### job-test-services-mysql
Dockerized job definition example with an additional volume
Dockerized job definition example with a mysql service
Job definition:
```yaml
job-with-volumes:
image: registry.gitlab.com/ercom/cijw4gitlab:1.0
stage: all-in-one
only:
- /^$/
job-test-services-mysql:
stage: build
variables:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password
CITBX_WAIT_FOR_SERVICE_START: 10
image: mysql
services:
- mysql
tags:
- test
script:
- test -f /path/to/my/volume/content
- 'echo "/path/to/my/volume/content file content: $(cat /path/to/my/volume/content)"'
- mysql -h mysql -u root -ppassword test -e 'SHOW VARIABLES LIKE "%version%";'
```
This project use:
### job-test-services-postgres
Dockerized job definition example with a postgresql service
Job definition:
* the functionality described at: [https://gitlab.com/ercom/cijw4gitlab](https://gitlab.com/ercom/cijw4gitlab)
* and the following volume: [https://gitlab.com/ercom/cijw4gitlab/tree/image-volume-example](https://gitlab.com/ercom/cijw4gitlab/tree/image-volume-example)
* This job need a runner with a volume /var/run/docker.sock to run an other container on the same docker daemon that gitlab-runner
```yaml
job-test-services-postgres:
stage: build
variables:
CITBX_WAIT_FOR_SERVICE_START: 10
image: postgres:9.4
services:
- name: postgres:9.4
alias: db-postgres
entrypoint: ["docker-entrypoint.sh"]
command: ["postgres"]
tags:
- test
script:
- psql -h db-postgres -U postgres -c 'select version();'
```
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment