Difference between revisions of "Gitlab CI/CD"

From UVOO Tech Wiki
Jump to navigation Jump to search
imported>Jeremy-busk
 
Line 12: Line 12:
  
 
if [ "$(git diff origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}...HEAD --name-only dir1 dir2 dir3" == "" ]; then echo "Skipped" && exit 0; fi
 
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.uvoo.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"
 +
```

Revision as of 17:57, 7 August 2020

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.uvoo.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"