Good afternoon
I started working with gitlab recently trying to figure out if it will fit with a need we have on an UX administration team.
I've created 3 servers on our cloud for testing as follows:
Server_1 Gitlab and Gitlab-CI
Server_2 Gitlab runners
Server_3 Scripts repository
The idea was to push a previous scripts repository to Gitlab and then have under control any change made to them and security issues.
I've installed Gitlab-Omnibus on server 1 and created user "test1" with his project Testproject1, after that I push some test scripts to the project. After this I installed the runners on Server_2 and configure against Gitlab, created a runner, register it and configured ssh keys against Server3
The problem here is as follows, any change made to any script on Gitlab's Testproject1 by user test1 triggers the runner to build and push the entire project to /home/user/build/"number"/number/Testproject1/ The script that performs these actions is located at that spot with the name "Testproject1.sh" with code like this in it:
if [[ -d $'builds/6461cd4f/0/test1/Testproject1/.git' ]]; then
echo $'\x1b[32;1mFetching changes...\x1b[0;m'
cd $'builds/6461cd4f/0/test1/Testproject1'
..... and so on.
We dont want the repository to be deploy at the user's home, I thought that configuring the file ".gitlab-ci.yml" with the desired deploy path and commands would be enough but the only thing I achieve with that is that the repository is deployed every time at the users home and at the path stated on the .yml file.
Anyone knows how to modify this behavior? is there any environmental variables or anything that cold fix this? or am I using wrong this CI feature?
The yml file for the runner is the following by the way:
job:
script:
- cd /opt/gitlab/aplicacion1
- git init .
- git add .
- git pull origin master
- pwd
- ls -ltra
tags:
- master
Thanks in advance
You could change the builds_dir
in gitlab-runner's config
the default builds_dir for gitlab-runner is $HOME/$version/build gitlab-link
Example:
/etc/gitlab-runner/config.toml:
[[runners]]
...
name = "runner_name"
executor = "ssh"
builds_dir = "/data/git_build"
[runners.ssh]
user = "user"
host = "192.xxx.xxx.xxx"
port = "22"
identity_file = "/home/user/.ssh/id_rsa"
or you can set the builds_dir when registering the gitlab-runner:
with arguments --builds-dir
gitlab-ci-multi-runner register \
--name "$NAME" \
--non-interactive \
--url " $URL" \
--tag-list $TAG \
--registration-token "$TOKEN" \
--executor "ssh" \
--builds-dir "$BUILD_DIR" \
--ssh-user "$SSH_USER" \
--ssh-host "$SSH_HOST" \
--ssh-port "$SSH_PORT" \
--ssh-identity-file "$SSH_IDENTITY_FILE"