Gitlab CI/CD

From UVOO Tech Wiki
Jump to navigation Jump to search

Using LXD/PyLXD with Gitlab

On you lxd-runner add gitlab-runner user to lxd group so it can spin up lxd containers.

sudo usermod --append --groups lxd gitlab-runner

Run only with changes on directory

https://docs.gitlab.com/ee/ci/yaml/#onlychanges-and-exceptchanges

or do some custom script

if [ "$(git diff origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}...HEAD --name-only dir1 dir2 dir3" == "" ]; then echo "Skipped" && exit 0; fi

Self-Signed Certs with Runners

SERVER=git.example.io
PORT=443
CERTIFICATE=/etc/gitlab-runner/certs/${SERVER}.crt

# Create the certificates hierarchy expected by gitlab
sudo mkdir -p $(dirname "$CERTIFICATE")

# Get the certificate in PEM format and store it
openssl s_client -connect ${SERVER}:${PORT} -showcerts </dev/null 2>/dev/null | sed -e '/-----BEGIN/,/-----END/!d' | sudo tee "$CERTIFICATE" >/dev/null
echo $CERTIFICATE
# Register your runner
gitlab-runner register --tls-ca-file="$CERTIFICATE"

or add to existing

[[runners]]
tls-ca-file = "/etc/gitlab-runner/certs/git.example.io.crt"
...