Commit bfc1abc4 authored by Stephane Bausseron's avatar Stephane Bausseron

Merge branch 'new_features' into 'master'

New features

See merge request ercom/citbx4gitlab!10
parents 464194d2 1f67d0e8
......@@ -43,15 +43,30 @@ job-with-volumes:
- test -f /path/to/my/volume/content
- 'echo "/path/to/my/volume/content file content: $(cat /path/to/my/volume/content)"'
job-test-services:
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
tags:
- test
script:
- mysql -h mysql -u root -ppassword test -e 'SHOW VARIABLES LIKE "%version%";'
job-test-services-postgres:
stage: build
variables:
CITBX_WAIT_FOR_SERVICE_START: 10
only:
- /^$/
image: postgres:9.4
services:
- name: postgres:9.4
alias: db-postgres
entrypoint: ["docker-entrypoint.sh"]
......@@ -59,7 +74,7 @@ job-test-services:
tags:
- test
script:
- "true"
- psql -h db-postgres -U postgres -c 'select version();'
job-test-services-ext:
image: registry.gitlab.com/ercom/cijw4gitlab:2.0.1
......
# Cangelog
## 3.0.0
* Add support of bash completion
* [FIX] remove warning from a test
* [FIX] unset CITBX_GIT_CLEAN for citbx_run_ext_job
* [CI] add job-test-services-mysql and job-test-services-postgres service example jobs
* Update docker run to use CITBX_JOB_SHELL
* [FIX] YAML variable treatment
* Improve messages/help formating
* Add debug-script option
* Remove deprecated JOB_EXT_FILE_NAME variable name
* [3rd] Update bashopts to the version 2.0.0
* Update fetch_file function for update command
* [FIX] docker run exit code on error
* [FIX] Preserve PATH environment variable in user mode
* Add VERSION and a CHANGELOG.md
## 2.2.10
* [FIX] unset CITBX_JOB_RUN_FILE_NAME in citbx_run_ext_job
## 2.2.9
* Improve git worktree support and preserve the working directory on shell mode
## 2.2.8
* Update variable name: CITBX_JOB_RUN_FILE_NAME
## 2.2.7
* Add ncore function
## 2.2.6
* [env-setup/ubuntu] Fix GIT LFS repository
## 2.2.5
* [env-setup/ubuntu] Update GIT LFS apt repository add
## 2.2.4
* Set git lfs as an optional feature
## 2.2.3
* [run] improve docker-dns detection
## 2.2.2
* [env-setup/ubuntu] [Fix] ca-certificates copy
* [Fix] read empty or invalid daemon.json
## 2.2.1
* [env-setup/ubuntu] Add --allow-change-held-packages option to apt-get remove docker.io & docker-engine
* [run] improve CI PROJECT ROOT DIR detection
## 2.2
* [FIX] service-privileged property variable name update
* Add GIT LFS support
* Improve docker-dns option check
## 2.1.1
* [FIX] service with custom commands with default entrypoint
* Add option to start service in privileged mode
## 2.1
* Add git-clean and group options
## 2.0.2
* [FIX] Eval YAML service properties
## 2.0.1
* [FIX] export variables to services
## 2.0
* Add Gitlab services support
## 1.3.2
* [fix] Prevent multiple call of citbx_job_finish
## 1.3.1
* add SIGINT SIGTERM to citbx_job_finish trap callback
## 1.3.0
* [fix] return the good error code on local job execution failure
* Add citbx_docker_run_add_args function
## 1.2.1
* [3rd] Update bashopts to the version 1.3.0
* Add citbx_export function
* [fix] Variable export the SHELL executor
## 1.2
* Changes:
* Add a check on the bash version
* Add submodule-strategy option for GIT_SUBMODULE_STRATEGY
* Add job executor option
* Add job script and job main func check
* Add image entrypoint support
* Remove CITBX_DOCKER_USER option
* reset PWD to CI_PROJECT_DIR before hooks execution
* [FIX] ubuntu setup
* Update the documentation
## 1.1
* Add CITBX_DEFAULT_JOB_SHELL property and CITBX_JOB_SHELL option
* Add job execution time
* Add update tool to fetch the last version
* Add gitlab GIT_SUBMODULE_STRATEGY support
## 1.0
* First stable release
This diff is collapsed.
PREFIX?=/usr/local
default:
install:
mkdir -p $(DESTDIR)/$(PREFIX)/bin
install citbx4gitlab $(DESTDIR)/$(PREFIX)/bin/
mkdir -p $(DESTDIR)/etc/bash_completion.d
cp bashcomp $(DESTDIR)/etc/bash_completion.d/citbx4gitlab
uninstall:
rm -f $(DESTDIR)/$(PREFIX)/bin/citbx4gitlab $(DESTDIR)/etc/bash_completion.d/citbx4gitlab
# citbx4gitlab - CI toolbox for Gitlab
This tool is installed in the system and add the following abilities:
* This tool can be run anywhere in a project containing the run.sh script
* This tool will run this script without have to specify the absolute/relative path
* This tool add BASH auto completion support
## To install:
```bash
$ sudo make install
```
## To uninstall:
```bash
$ sudo make uninstall
```
#!/bin/bash -e
# citbx4gitlab: CI tools for Gitlab
# Copyright (C) 2017 ERCOM - Emeric Verschuur <emeric@mbedsys.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
_citbx4gitlab_compgen() {
local cur prev cmd result line
_init_completion -s || return
cur=${COMP_WORDS[COMP_CWORD]}
cmd=$(eval echo "${COMP_WORDS[1]}")
if [ "0$COMP_CWORD" -eq 1 ]; then
result=$(compgen -W "$(CITBX_BASHCOMP=commands citbx4gitlab 2>/dev/null || true)" -- "$cur")
else
case "$cur" in
-*)
result=$(compgen -W "$(CITBX_BASHCOMP=opts citbx4gitlab "$cmd" 2>/dev/null || true)" -- "$cur")
;;
--*)
result=$(compgen -W "$(CITBX_BASHCOMP=longopts citbx4gitlab "$cmd" 2>/dev/null || true)" -- "$cur")
;;
*)
prev=${COMP_WORDS[$((0$COMP_CWORD - 1))]}
case "$prev" in
-*)
result=$(compgen -W "$(CITBX_BASHCOMP=$prev citbx4gitlab "$cmd" 2>/dev/null || true)" -- "$cur")
if [ -z "$result" ]; then
_filedir
return 0
fi
;;
esac
;;
esac
fi
if [ -n "$result" ]; then
COMPREPLY=()
while read -r line; do
COMPREPLY+=("$(printf "%q\n" "$line")")
done <<< "$result"
fi
return 0
} &&
complete -F _citbx4gitlab_compgen citbx4gitlab
#!/bin/bash -e
# citbx4gitlab: CI tools for Gitlab
# Copyright (C) 2017 ERCOM - Emeric Verschuur <emeric@mbedsys.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Print an error message and exit with error status 1
print_critical() {
>&2 printf "\e[91m[CRIT] %s\e[0m\n" "$@"
exit 1
}
# Print an error message
print_error() {
>&2 printf "\e[91m[ERRO] %s\e[0m\n" "$@"
}
# Print a warning message
print_warning() {
>&2 printf "\e[93m[WARN] %s\e[0m\n" "$@"
}
# Print a note message
print_note() {
printf "[NOTE] %s\n" "$@"
}
# Pring an info message
print_info() {
printf "\e[92m[INFO] %s\e[0m\n" "$@"
}
CI_PROJECT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || true)"
if [ -z "$CI_PROJECT_DIR" ]; then
print_critical "Not a git repository"
fi
CITBX_SEARCH_PATH=${CITBX_SEARCH_PATH:-":tools/gitlab-ci"}
CITBX_RUN_PATH=$(
IFS=':'
for d in $CITBX_SEARCH_PATH; do
if grep -q 'Bourne-Again shell script, ASCII text executable$' \
<<< "$(LC_ALL=C file $CI_PROJECT_DIR/$d/run.sh 2> /dev/null)"; then
echo $CI_PROJECT_DIR/$d/run.sh
fi
done
)
if [ -z "$CITBX_RUN_PATH" ]; then
print_critical "Unable to find the run.sh tool from the repository \"$CI_PROJECT_DIR\"" \
" => You may have to update the CITBX_SEARCH_PATH to add the suitable run.sh retative directory from the project root" \
" e.g.: add export CITBX_SEARCH_PATH=\"$CITBX_SEARCH_PATH:your/custom/dir\" to your environment"
fi
# BASH COMP MODE: Check if the tool support bash completion
if [ -n "$CITBX_BASHCOMP" ]; then
CITBX_VERSION=$(awk -F = '
/^CITBX_VERSION=/ {
print $2
}
NR > 50 {
exit
}' $CITBX_RUN_PATH 2> /dev/null || true)
# skip bash completion for CITBX_VERSION < 3.x.x
test "0${CITBX_VERSION%%.*}" -ge 3 || exit
fi
export CITBX_TOOL_NAME=$(basename $0)
exec $CITBX_RUN_PATH "$@"
print_critical "Unable to run $CITBX_RUN_PATH tool"
......@@ -109,11 +109,12 @@ if grep -q '^ *\<DOCKER_OPTS\>' /etc/default/docker; then
fi
_sudo cat /etc/docker/daemon.json |
jq ". + {
\"bip\": \"$CITBX_DOCKER_BIP\",
\"fixed-cidr\": \"$CITBX_DOCKER_FIXED_CIDR\",
\"dns\": $(bashopts_dump_array "string" "${CITBX_DOCKER_DNS_LIST[@]}")
}" | sudo_sponge /etc/docker/daemon.json
jq '. + {
"bip": "'"$CITBX_DOCKER_BIP"'",
"fixed-cidr": "'"$CITBX_DOCKER_FIXED_CIDR"'",
"dns": '"$(bashopts_dump_array "string" "${CITBX_DOCKER_DNS_LIST[@]}")"',
"storage-driver": "'"$CITBX_DOCKER_STORAGE_DRIVER"'"
}' | sudo_sponge /etc/docker/daemon.json
# Add user SSL ROOT CA
if [ -d $CITBX_ABS_DIR/ca-certificates ]; then
......
This diff is collapsed.
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