diff --git a/industrial_ci/src/credential-helpers/gitlab-credential-helper b/industrial_ci/src/credential-helpers/gitlab-credential-helper new file mode 100755 index 000000000..bf2f0b884 --- /dev/null +++ b/industrial_ci/src/credential-helpers/gitlab-credential-helper @@ -0,0 +1,31 @@ +#!/bin/sh -e + +# Copyright (c) 2021, Mathias Lüdtke +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing@, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ "$1" = "get" ]; then + if [ -n "${CI_SERVER_PROTOCOL}" ]; then + echo "protocol=${CI_SERVER_PROTOCOL}" + fi + if [ -n "${CI_SERVER_HOST}" ]; then + if [ -n "${CI_SERVER_PORT}" ]; then + echo "host=${CI_SERVER_HOST}:${CI_SERVER_PORT}" + else + echo "host=${CI_SERVER_HOST}" + fi + fi + echo "username=gitlab-ci-token" + echo "password=${CI_JOB_TOKEN}" +fi diff --git a/industrial_ci/src/isolation/docker.env b/industrial_ci/src/isolation/docker.env index a637538da..963971ef3 100644 --- a/industrial_ci/src/isolation/docker.env +++ b/industrial_ci/src/isolation/docker.env @@ -10,6 +10,11 @@ CATKIN_LINT CATKIN_LINT_ARGS CC CFLAGS +CI_JOB_TOKEN +CI_SERVER_HOST +CI_SERVER_PORT +CI_SERVER_PROTOCOL +CI_SERVER_URL CLANG_FORMAT_CHECK CLANG_FORMAT_VERSION CLANG_TIDY @@ -22,6 +27,7 @@ CXXFLAGS DEBUG_BASH DOWNSTREAM_CMAKE_ARGS DOWNSTREAM_WORKSPACE +GITLAB_CI HASHKEY_SKS # EXPECT_EXIT_CODE, do not pass to make sure code is checked on the outer level only IMMEDIATE_TEST_OUTPUT diff --git a/industrial_ci/src/workspace.sh b/industrial_ci/src/workspace.sh index 360c5ebc5..956f2f526 100644 --- a/industrial_ci/src/workspace.sh +++ b/industrial_ci/src/workspace.sh @@ -111,11 +111,20 @@ function ici_install_pypi_pkgs_for_command { ici_exec_for_command "$command" ici_pip_install "$@" } +function ici_setup_git_credential_helper { + local url=$1; shift + local helper=$1; shift + git config --global "credential.${url}.helper" "${ICI_SRC_PATH}/credential-helpers/${helper}" +} + function ici_setup_git_client { ici_install_pkgs_for_command git git-core if [ -d ~/.ssh ]; then ici_install_pkgs_for_command ssh ssh-client fi + if [ "${GITLAB_CI:-false}" = "true" ] && [ -n "${CI_SERVER_URL:-}" ] && [ -n "${CI_JOB_TOKEN:-}" ]; then + ici_setup_git_credential_helper "${CI_SERVER_URL}" "gitlab-credential-helper" + fi } function ici_vcs_import {