Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for automatic setup of GitLab CI credentials #594

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions industrial_ci/src/credential-helpers/gitlab-credential-helper
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions industrial_ci/src/isolation/docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions industrial_ci/src/workspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down