Closed evbo closed 6 years ago
So this appears to be related to a gitlab bug: https://gitlab.com/gitlab-org/gitlab-ce/issues/22723
Further, it seems necessary to specify the port (8088 in my case). How do I configure the port to use in this plugin?
If I manually try to clone using the CI runners' token, I can repeat this issue:
git clone http://gitlab-ci-token:token@servername.com/group/projectname.git
Cloning into 'projectname'...
fatal: repository 'http://gitlab-ci-token:token@servername.com/group/projectname.git/' not found
git clone http://gitlab-ci-token:token@servername.com:8088/group/projectname.git
Cloning into 'projectname'...
fatal: Authentication failed for 'http://gitlab-ci-token:token@servername.com:8088/group/projectname.git/'
and then, as per that gitlab issue, if I use a personal auth token it works:
git clone http://username:authToken@servername.com:8088/group/projectname.git
Cloning into 'projectname'...
remote: Counting objects: 103, done.
remote: Compressing objects: 100% (58/58), done.
remote: Total 103 (delta 33), reused 82 (delta 29)
Receiving objects: 100% (103/103), 178.02 KiB | 0 bytes/s, done.
Resolving deltas: 100% (118/118), done.
So, how can I modify this plugin to clone with an explicit port (8088)? And how can I configure it to use a user auth token rather than CI runner token?
I'm still fairly new to gitlab, but I'm getting the feeling that this may be either a bug or at the very least an unclear feature with gitlab itself (not this sonar plugin). Following this recommendation, I essentially disabled cloning for the runner and performed the clone myself using shell commands: https://gitlab.com/gitlab-org/gitlab-runner/issues/1884
Here is what my before_script
looked like to achieve this per instruction in the link above:
before_script:
## --------------------
## hard-coded variables that are not necessarily constant if gitlab config is changed:
## auth token is set for the gitlab-runner user in profile settings
- AUTH_TOKEN=someAuthTokenHardCodedUnfortunately
## "Runner Token" is set in the Runners admin console:
- RUNNER_TOKEN=someRunnerTokenHardCodedUnfortunately
## we assume just a single (0th) build step:
- BUILD_DIR=/home/gitlab-runner/builds/$RUNNER_TOKEN/0
## --------------------
## ensure access to mvn command
- export PATH=$PATH:/path/to/apache-maven-3.2.5/bin
## clean the working directory
- cd $BUILD_DIR
- CLONE_DIR="$BUILD_DIR/$CI_PROJECT_PATH"
- rm -rf $CLONE_DIR
- mkdir -p $CLONE_DIR
## clone the project each time (inefficient, consider performing fetch instead if it already exists)
- git config --global user.email "my.email@some.com"
- git config --global user.name "gitlab-runner"
- git clone http://gitlab-runner:$AUTH_TOKEN@servername.com:8088/group/projectName.git $CLONE_DIR
- cd $CLONE_DIR
So I'll close this issue as there's plenty of gitlab issues posted to suggest the problem I'm experiencing is not due to the plugin but the manner in which git repos are cloned before running plugins on them, e.g.:
https://gitlab.com/gitlab-org/gitlab-ce/issues/22723 https://stackoverflow.com/questions/39208420/how-do-i-enable-cloning-over-ssh-for-a-gitlab-runner https://gitlab.com/gitlab-org/gitlab-runner/issues/1884
Hi, I have followed the readme for setting up this plugin but am unable to run a job due to the below failure. What mistake did I make in configuration?
Job Failure:
I created a "sonar" user in gitlab with developer role. I set the token in my sonar user that was created for that same user.
My GitLab url is set to:
My GitLab project id is set to (the repository):
My .gitlab-ci.yml is: