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 @@ ...@@ -2,7 +2,7 @@
image: ubuntu:16.04 image: ubuntu:16.04
variables: variables:
GLOBALJOBVAR: "blobal variable" GLOBALJOBVAR: "global variable"
after_script: after_script:
- echo "job ${CI_JOB_NAME} end" - echo "job ${CI_JOB_NAME} end"
...@@ -34,23 +34,12 @@ job-advanced: ...@@ -34,23 +34,12 @@ job-advanced:
- echo ${JOBADVAR} - echo ${JOBADVAR}
- tools/gitlab-ci/run.sh - 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: job-test-services-mysql:
stage: build stage: build
variables: variables:
MYSQL_DATABASE: test MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: password MYSQL_ROOT_PASSWORD: password
CITBX_WAIT_FOR_SERVICE_START: 10 CITBX_WAIT_FOR_SERVICE_START: 10
only:
- /^$/
image: mysql image: mysql
services: services:
- mysql - mysql
...@@ -63,8 +52,6 @@ job-test-services-postgres: ...@@ -63,8 +52,6 @@ job-test-services-postgres:
stage: build stage: build
variables: variables:
CITBX_WAIT_FOR_SERVICE_START: 10 CITBX_WAIT_FOR_SERVICE_START: 10
only:
- /^$/
image: postgres:9.4 image: postgres:9.4
services: services:
- name: postgres:9.4 - name: postgres:9.4
...@@ -75,16 +62,3 @@ job-test-services-postgres: ...@@ -75,16 +62,3 @@ job-test-services-postgres:
- test - test
script: script:
- psql -h db-postgres -U postgres -c 'select version();' - 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 ...@@ -7,46 +7,45 @@ This toolbox can be used to
## Table of contents ## Table of contents
* [The project](#the-project) * [The project](#the-project)
* [Use case: Standard Gitlab-CI pipeline job](#use-case-standard-gitlab-ci-pipeline-job) * [Use case: Standard Gitlab-CI pipeline job](#use-case-standard-gitlab-ci-pipeline-job)
* [Run a specific job locally](#run-a-specific-job-locally) * [Run a specific job locally](#run-a-specific-job-locally)
+ [Fist solution: using gitlab-runner tool](#fist-solution-using-gitlab-runner-tool) * [Fist solution: using gitlab-runner tool](#fist-solution-using-gitlab-runner-tool)
+ [Other solution: Use run.sh tool](#other-solution-use-runsh-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 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 job](#write-a-job)
+ [Write a module](#write-a-module) * [Write a module](#write-a-module)
+ [Useful function list](#useful-function-list) * [Useful function list](#useful-function-list)
* [Job examples](#job-examples) * [Job examples](#job-examples)
+ [job-minimal](#job-minimal) * [job-minimal](#job-minimal)
+ [job-with-before-after-script](#job-with-before-after-script) * [job-with-before-after-script](#job-with-before-after-script)
+ [job-advanced](#job-advanced) * [job-advanced](#job-advanced)
+ [job-with-volumes](#job-with-volumes) * [job-test-services-mysql](#job-test-services-mysql)
* [job-test-services-postgres](#job-test-services-postgres)
## The project ## The project
The citbx4gitlab project tree A citbx4gitlab integration example into a project tree
``` ```
├── .ci-job-wrapper.yml
├── .git
├── .gitlab-ci.yml ├── .gitlab-ci.yml
├── doc ├── tools
├── LICENSE │   └── gitlab-ci
├── README.md │   ├── 3rdparty
└── tools │   │   └── bashopts.sh
└── gitlab-ci │   ├── citbx.properties
├── 3rdparty │   ├── env-setup
│ └── bashopts.sh │   │   ├── common.sh
├── citbx.properties │   │   ├── gentoo.sh
├── env-setup │   │   └── ubuntu.sh
│ └── ubuntu.sh │   ├── modules
├── modules │   │   ├── ccache.sh
│ ├── ccache.sh │   │   ├── dockerimg.sh
└── example.sh │   │   └── example.sh
├── run -> run.sh │   ├── run -> run.sh
├── run.d │   ├── run.d
└── job-advanced.sh │   │   └── job-advanced.sh
└── run.sh │   └── run.sh
``` ```
The minimal element list: The minimal element list:
...@@ -55,13 +54,16 @@ The minimal element list: ...@@ -55,13 +54,16 @@ The minimal element list:
* ```run.sh```: tool to run Gitlab-CI job on the workstation * ```run.sh```: tool to run Gitlab-CI job on the workstation
* ```bashopts.sh```: dependency required by run.sh * ```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 * ```env-setup```: directory containing the workstation environment setup script
* ```citbx.properties```: CI toolbox project properties * ```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 ## Use case: Standard Gitlab-CI pipeline job
The following schema describe the standard execution of a job called "J" in a Gitlab-CI pipeline 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: ...@@ -88,7 +90,7 @@ In addition you have to:
* Commit the changes to be taken in board by the gitlab-runner * Commit the changes to be taken in board by the gitlab-runner
* Add gitlab-runner executor option like ```--docker-image``` * 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: This tool is able to:
...@@ -101,6 +103,17 @@ Additional advanced run.sh tool functionalities: ...@@ -101,6 +103,17 @@ Additional advanced run.sh tool functionalities:
* Add ability to run a shell into the suitable job docker environment * Add ability to run a shell into the suitable job docker environment
* Split job parts in modular format (Job parts, modules, ...) * 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: Know limitations:
* Only applicable for docker and shell executor * Only applicable for docker and shell executor
...@@ -230,25 +243,47 @@ Job run: ...@@ -230,25 +243,47 @@ Job run:
![Job advanced](doc/TestCaseJobAvanced.png) ![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: Job definition:
```yaml ```yaml
job-with-volumes: job-test-services-mysql:
image: registry.gitlab.com/ercom/cijw4gitlab:1.0 stage: build
stage: all-in-one variables:
only: MYSQL_DATABASE: test
- /^$/ MYSQL_ROOT_PASSWORD: password
CITBX_WAIT_FOR_SERVICE_START: 10
image: mysql
services:
- mysql
tags:
- test
script: script:
- test -f /path/to/my/volume/content - mysql -h mysql -u root -ppassword test -e 'SHOW VARIABLES LIKE "%version%";'
- 'echo "/path/to/my/volume/content file content: $(cat /path/to/my/volume/content)"'
``` ```
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) ```yaml
* and the following volume: [https://gitlab.com/ercom/cijw4gitlab/tree/image-volume-example](https://gitlab.com/ercom/cijw4gitlab/tree/image-volume-example) job-test-services-postgres:
* 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 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