ceph-csi/deploy/checkout-repo.sh
Niels de Vos 234471af33 ci: allow /opt/build for git repository when deploying jobs
When Jenkins Jobs have been modified, they should get deployed in the
Jenkins environment. This seems to fail with the following error:

```
Initialized empty Git repository in /opt/build/.git/
fatal: detected dubious ownership in repository at '/opt/build'
To add an exception for this directory, call:

	git config --global --add safe.directory /opt/build
```

By marking /opt/build as a safe directory in the global git
configuration file, this problem should not occur anymore.

Signed-off-by: Niels de Vos <ndevos@redhat.com>
2023-01-30 15:15:06 +01:00

19 lines
383 B
Bash
Executable File

#!/bin/sh
fail() {
echo "${@}" > /dev/stderr
exit 1
}
[ -n "${GIT_REPO}" ] || fail 'GIT_REPO environment variable not set'
[ -n "${GIT_REF}" ] || fail 'GIT_REF environment variable not set'
# exit in case a command fails
set -e
git config --global --add safe.directory ${PWD}
git init .
git remote add origin "${GIT_REPO}"
git fetch origin "${GIT_REF}"
git checkout FETCH_HEAD