-
Notifications
You must be signed in to change notification settings - Fork 130
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
Document Github Actions and Gitlab CI with private repositories #574
Comments
For our private GitLab instance, we are using token placement with The before script looks like this:
Our URL is here hardcoded, it should be added as an environment variable to make this more flexible. |
@floweisshardt: It turned out that - uses: 'ros-industrial/industrial_ci@master'
env:
ROS_DISTRO: melodic
TARGET_WORKSPACE: test.repos
ADDITIONAL_DEBS: git-core
AFTER_INIT: git config --global url."https://token:${{secrets.GITHUBPAT}}@github.com/".insteadOf "https://github.com/"
This should work for you (instead of the 3 sed lines): variables:
ADDITIONAL_DEBS: git-core
AFTER_INIT: git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ipr.kit.edu/".insteadOf "https://gitlab.ipr.kit.edu/" Please double check that the token is not exposed anywhere. |
@ipa-mdl this looks great! Thanks, I will try to optimize our CI configurations. |
@ipa-mdl 👍 thanks a lot. That works for our use case. |
The only downside of this approach is that it might not work with |
I still have some troubles to get this fully integrated. Seems as this works fine with self-hosted runners on my pc but as soon as I use github hosted runners the jobs fail during
I assume it's waiting for some user input
|
adding
solves this |
@floweisshardt: the PAT trick does not use ssh, so you would need to replace the git@ paths
If your build is just stuck because the known host, then there should be a way to automate it. |
One important note: Apparently, data access to a self-hosted runner needs to be paid for (free limit depends on subscription plan), if it gets authenticated with a PAT. |
Hey @floweisshardt , I am having troubles make it running on a self-hosted runner. Could you perhaps post your workflow? Thanks! |
@eliabruni here's my workflow config:
in the
|
Many thanks @floweisshardt , that works for me too! :)) |
the script |
Are there plans on configuring Git to use the CI token automatically for the GitLab CI? (By providing a credential helper echoing the CI_JOB_TOKEN environment variable) |
You mean this? AFTER_INIT: git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/".insteadOf "${CI_SERVER_URL}/" Should be possible. |
I rather thought of something where the credentials are not stored on disk. #!/bin/bash
if [ "$1" = "get" ]; then
echo "username=gitlab-ci-token"
echo "password=${CI_JOB_TOKEN}"
fi Within the setup scripts of the CI environment:
|
That's the bigger issue. Right now there is no defined time for executing the config line. |
Is that so? the token is valid during the execution of the whole pipeline, but it might have to be passed into the nested docker container on build and execution. EDIT: Proof of concept: variables:
ADDITIONAL_DEBS: "git"
DOCKER_RUN_OPTS: "--mount type=bind,src=${CI_PROJECT_DIR}/.gitconfig,dst=/root/.gitconfig,readonly --env CI_JOB_TOKEN"
before_script:
- git config --file ${CI_PROJECT_DIR}/.gitconfig credential."${CI_SERVER_URL}".helper '!f() { test "$1" = get && echo "username=gitlab-ci-token" && echo "password=${CI_JOB_TOKEN}"; }; f'; For some reasons, mounting the git config file from EDIT 2: Regarding this:
I would propose configuring git in |
I think I meant "job" and not "build". From the documentation:
Yes, this would make sense. |
It depends on the Docker runner. Normally |
You may take look at #594. However, it is currently GitLab-specific, especially regarding the EDIT: Now I see your point regarding the validity of the CI job token. That's true, storing the job token somewhere is not fatal since it will be invalid after a few minutes. That makes the |
The text was updated successfully, but these errors were encountered: