Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • seco-ne/yocto/infrastructure/gitlab-ci
1 result
Show changes
Commits on Source (1)
......@@ -49,20 +49,50 @@ workflow:
- echo "Setup Git Credentials Cache"
- git config --global credential.helper 'cache --timeout 86400'
- git config --global --add safe.directory "*"
- while read -r credentials; do
TOKEN_PATH=$(echo $credentials | cut -d':' -f1);
TOKEN_USER=$(echo $credentials | cut -d':' -f2);
TOKEN=$(echo $credentials | cut -d':' -f3);
if [ -z "${TOKEN_USER}" ] || [ -z "${TOKEN}" ]; then
echo "Invalid Git Credentials entry; Skipping ...";
continue;
fi
# Following format should be used for GITLAB_PRIVATE_TOKEN:
# protocol://host.domain/path:username:token
# path is mandatory. If it needs to be empty, please use
# http://some.domain.git/:username:token
# Examples:
# https://some.domain.git/some/path:username:token
# http://some.domain.git:port/some/path:username:token
# git://git.domain/user/repo.git:username:token
# Example empty path:
# http://some.domain.git/:username:token
# A format without a protocol will be treated as a local repository.
# For example, seco-ne/yocto/infrastructure/ci-test:username:token will become
# https://git.seco.com/seco-ne/yocto/infrastructure/ci-test:username:token
# For multiple tokens use "~" as a separator
# https://domain.git/some/path:username:token~http://other_domain.git/some/path:username:token
- original_ifs="$IFS";
IFS="~";
while read -r creds; do
for credentials in ${creds[@]}; do
TOKEN_HOST="git.seco.com";
TOKEN_PROTOCOL="https";
if echo $credentials | grep -q "://"; then
TOKEN_PROTOCOL=$(echo "$credentials" | awk -F '://' '{print $1}');
credentials=$(echo $credentials | sed 's,^[^:]*://,,');
TOKEN_HOST=$(echo "$credentials" | awk -F '/' '{print $1}' );
credentials=$(echo $credentials | sed 's,^[^/]*/,,');
fi
if [ "$(echo $credentials | grep -o ':' | wc -l)" -ne "2" ]; then
echo "Invalid Git Credentials entry; Skipping ...";
continue;
fi
TOKEN_PATH=$(echo $credentials | cut -d':' -f1);
TOKEN_USER=$(echo $credentials | cut -d':' -f2);
TOKEN=$(echo $credentials | cut -d':' -f3);
printf "protocol=https\nhost=git.seco.com\npath=%s\nusername=%s\npassword=%s\n"
"${TOKEN_PATH}" "${TOKEN_USER}" "${TOKEN}" |
printf "protocol=%s\nhost=%s\npath=%s\nusername=%s\npassword=%s\n"
"${TOKEN_PROTOCOL}" "${TOKEN_HOST}" "${TOKEN_PATH}" "${TOKEN_USER}" "${TOKEN}" |
git credential approve;
done <<< "${GITLAB_PRIVATE_TOKEN}"
done;
done <<< "${GITLAB_PRIVATE_TOKEN}";
IFS=$original_ifs;
.repo_checkout: &repo_checkout
- echo "Perform repo checkout"
......