Commit 45d4de66 authored by Emeric Verschuur's avatar Emeric Verschuur

Add GIT LFS support

parent 385c843d
......@@ -15,3 +15,6 @@ CITBX_DEFAULT_JOB_SHELL="/bin/bash"
# Set service dockers in privileged mode as default
#CITBX_DEFAULT_SERVICE_DOCKER_PRIVILEGED="true"
#
# Enable git lfs by default
#CITBX_DEFAULT_GIT_LFS_ENABLED="true"
#
......@@ -30,31 +30,38 @@ if ubuntu_is_installed docker-engine; then
_sudo /etc/init.d/docker stop
_sudo apt-get remove -y docker-engine
fi
_sudo apt-get update
_sudo apt-get install -y aufs-tools \
linux-image-extra-virtual \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
if grep -qr 'download.docker.com' /etc/apt/; then
print_note "Docker apt repository is already present."
else
print_note "Adding docker apt repository..."
# setup - pre install
_sudo apt-get update
_sudo apt-get install -y aufs-tools \
linux-image-extra-virtual \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
# add docker repo
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | _sudo apt-key add -
_sudo add-apt-repository \
"deb [arch=amd64] http://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
_sudo apt-get update
fi
if grep -qr 'git-lfs' /etc/apt/; then
print_note "GIT LFS apt repository is already present."
else
print_note "Adding GIT LFS apt repository..."
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
fi
_sudo apt-get update
_sudo apt-get -y install docker-ce \
gawk \
python-yaml \
moreutils \
jq
jq \
git-lfs
if [ "${USER}" != "root" ]; then
_sudo gpasswd -a ${USER} docker
......
......@@ -191,6 +191,9 @@ done
if [ "$(echo "true" | yaml2json 2>/dev/null)" != "true" ]; then
CITBX_MISSING_PKGS+=("python-yaml")
fi
if ! git lfs version > /dev/null 2>&1; then
CITBX_MISSING_PKGS+=("git-lfs")
fi
if [ ! -f $CI_PROJECT_DIR/.gitlab-ci.yml ]; then
print_critical "$CI_PROJECT_DIR/.gitlab-ci.yml file not found"
......@@ -388,6 +391,7 @@ case "$command" in
# Properties check
CITBX_DEFAULT_JOB_SHELL=${CITBX_DEFAULT_JOB_SHELL:-/bin/sh}
CITBX_DEFAULT_SERVICE_DOCKER_PRIVILEGED=${CITBX_DEFAULT_SERVICE_DOCKER_PRIVILEGED:-false}
CITBX_DEFAULT_GIT_LFS_ENABLED=${CITBX_DEFAULT_GIT_LFS_ENABLED:-false}
# Command check
pattern='\b'"$command"'\b'
if ! [[ "${CITBX_JOB_LIST[*]}" =~ $pattern ]]; then
......@@ -429,6 +433,8 @@ case "$command" in
-d "Git submodule strategy (none, normal or recursive)" -t string -v "${GIT_SUBMODULE_STRATEGY:-none}"
bashopts_declare -n CITBX_GIT_CLEAN -l git-clean -o c \
-d "Perfom a git clean -fdx in the main project and submodules" -t boolean
bashopts_declare -n CITBX_GIT_LFS_ENABLED -l git-lfs -v "$CITBX_DEFAULT_GIT_LFS_ENABLED" \
-d "Enable git LFS support" -t boolean
declare_opts=()
if [ -n "$DEFAULT_CI_REGISTRY" ]; then
declare_opts+=(-v "$DEFAULT_CI_REGISTRY")
......@@ -568,7 +574,7 @@ exit $__job_exit_code__
CITBX_JOB_SCRIPT="'"${CITBX_JOB_SCRIPT//\'/\'\\\'\'}"'"
# Fetch git submodules
if [ -n "$GIT_SUBMODULE_STRATEGY" ] && [ "$GIT_SUBMODULE_STRATEGY" != "none" ]; then
if [ "$GIT_SUBMODULE_STRATEGY" != "none" ]; then
GIT_SUBMODULE_ARGS=()
case "$GIT_SUBMODULE_STRATEGY" in
normal)
......@@ -587,8 +593,15 @@ fi
if [ "$CITBX_GIT_CLEAN" == "true" ]; then
git clean -fdx
if [ -n "$GIT_SUBMODULE_STRATEGY" ] && [ "$GIT_SUBMODULE_STRATEGY" != "none" ]; then
git submodule foreach "${GIT_SUBMODULE_ARGS[@]}" git clean -xfd
if [ "$GIT_SUBMODULE_STRATEGY" != "none" ]; then
git submodule foreach "${GIT_SUBMODULE_ARGS[@]}" git clean -fdx
fi
fi
if [ "$CITBX_GIT_LFS_ENABLED" == "true" ]; then
git lfs pull
if [ "$GIT_SUBMODULE_STRATEGY" != "none" ]; then
git submodule foreach "${GIT_SUBMODULE_ARGS[@]}" git lfs pull
fi
fi
......
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