Git lab build fails with 403 error - gitlab-ci

i am trying to set up gitlab runner for a project, and when i try to run the build i am getting an 403 error.
Where can i check the build logs other than doing systemctl status gitlab-runner?
git-lab-runner Version: 9.5.1
build error:
Running with gitlab-ci-multi-runner 9.5.1 (96b34cc)
on ci (3aa5e67d)
Using Docker executor with image docker.xxx.com/terraform:latest ...
Using docker image sha256:134722953932eb772ab67a8b6e865aae2da7fe6ba3f09e757ea09e0d416ec203 for predefined container...
Pulling docker image docker.xxx.com/terraform:latest ...
Using docker image docker.xxx.com/terraform:latest ID=sha256:fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx for build container...
Running on runner-3aa5e67d-project-184-concurrent-0 via ip-10-xx-xx-xx...
Cloning repository...
Cloning into '/builds/bi/abc'...
fatal: unable to access 'https://gitlab.xxxx.com/folder/abc.git/': The requested URL returned error: 403
ERROR: Job failed: exit code 1
runner config:
concurrent = 1
check_interval = 0
[[runners]]
name = "ci"
url = "http://gitlab.xxx.com"
token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
executor = "docker"
[runners.docker]
tls_verify = false
image = "docker.xxx.com/terraform:latest"
privileged = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
[runners.cache]
I had configured gitlab runner to a different project but it did not ask me to add the user to the members, how can i troubleshoot this error, i believe its an authentication error.

Related

gitlabrunner unable to clone repo

I am using gitlab UI to deploy rancher via TF, job runs on GitLab Runner as a container on linux VM.
below is the config of.gitlab-ci.yml
- echo "https://gitlab-ci-token:${CI_JOB_TOKEN}#git.myservice.demo.com" >> ~/.git-credentials
- git config --global credential.helper 'store --file ~/.git-credentials'
when i run the pipeline it fail to clone the repo , i have active deployment token not sure why its failing.
Any guidance will be appreciated as very new to gitlab.
Pipeline error
Running with gitlab-runner 13.2.1 (efa30e33)
on b069898257b6 HpcxYCyA
Preparing the "docker" executor
00:05
Using Docker executor with image hashicorp/terraform:0.12.29 ...
Pulling docker image hashicorp/terraform:0.12.29 ...
Using docker image sha256:323b4bbc567117d19a68bcfe71e87ce9be855674005f645e41c8faedf4c263cb for hashicorp/terraform:0.12.29 ...
Preparing environment
00:02
Running on runner-hpcxycya-project-257-concurrent-0 via 7d0ddeb92b75...
Getting source from Git repository
00:02
$ git config --global http.proxy $HTTP_PROXY; git config --global https.proxy $HTTPS_PROXY
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/demo/rancher-prod/.git/
fatal: unable to access 'https://git.myservice.demo.com/demo/rancher-prod.git/': SSL certificate problem: unable to get local issuer certificate
ERROR: Job failed: exit code 1
# openssl s_client -connect git.myserives.demo.com:443
140605252743616:error:0200206E:system library:connect:Connection timed out:../crypto/bio/b_sock2.c:110:
140605252743616:error:2008A067:BIO routines:BIO_connect:connect error:../crypto/bio/b_sock2.c:111:
connect:errno=110

Gitlab Auto Deploy failing to connect to Docker

I've got Gitlab installed on Kubernetes using Helm and try to get Auto DevOps working but I'm getting the following issue from the Auto DevOps pipeline:
Executing "step_script" stage of the job script 00:01
$ if [[ -z "$CI_COMMIT_TAG" ]]; then # collapsed multi-line command
$ /build/build.sh
Logging in to GitLab Container Registry with CI credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
Building Dockerfile-based application...
Attempting to pull a previously built image for use with --cache-from...
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
No previously cached image found. The docker build will proceed without using a cached image
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
Cleaning up file based variables 00:00
ERROR: Job failed: command terminated with exit code 1
I've read abt the issues with Docker-in-Docker, but I couldn't get it to work.
I also tried setting the DOCKER_HOST: tcp://docker:2375/ variable, but I still get the same error.
Cannot connect to the Docker daemon at tcp://docker:2375/. Is the docker daemon running?
My Gitlab Runner Helm values looks like this:
gitlabUrl: https://gitlab.mydomain.com
privileged: true
rbac:
create: true
runnerRegistrationToken: mytoken
runners:
config: |
[[runners]]
executor = "docker"
privileged = true
environment = ["DOCKER_TLS_CERTDIR="]
[runners.docker]
tls_verify = false
privileged = true
I tried using the Auto-DevOps .gitlab-ci.yml template.
My cluster is integrated into Gitlab using the cluster certificate method and running simple CI/CD like
test_project:
stage: test
script:
- npm run test
Works fine
I tried docker:18.09.7, docker:19.03.1 and docker:latest (and the corresponding -dind services, with or without setting DOCKER_HOST: tcp://docker:2375/)
I don't know what I'm missing.
// Update
I got this issue resolved with help from the Gitlab Support.
My issue was that I had to use [runners.kubernetes] config and set privileged to true there. I was only setting it in [runners.docker] as I thought that Kubernetes Gitlab Runners would that config.

Why my gitlab runner try to fetch repo with a different url other than which I configured?

I deployed a gitlab runner and a gitlab instance on the same server using docker, after that, I tried to run a few samples to test my runner, but in the first job it always tells me that it can't access my repository. The weird thing is that it try to access a totally different URL instaed of the one in config.toml.
Here is my config:
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "******"
url = "http://172.17.0.3:8010/"
token = "*********"
executor = "docker"
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
[runners.docker]
tls_verify = false
image = "ubuntu"
privileged = false
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/cache"]
shm_size = 0
The http://172.17.0.3:8010/ is exact the ip of my gitlab instance inside the docker network.
Here is where the runner try to get my code:
Running with gitlab-runner 13.12.0 (7a6612da)
on third runner 2ieTUrD1
Preparing the "docker" executor
Using Docker executor with image ubuntu:focal ...
Pulling docker image ubuntu:focal ...
Using docker image sha256:7e0aa2d69a153215c790488ed1fcec162015e973e49962d438e18249d16fa9bd for ubuntu:focal with digest ubuntu#sha256:adf73ca014822ad8237623d388cedf4d5346aa72c270c5acc01431cc93e18e2d ...
Preparing environment
00:01
Running on runner-2ieturd1-project-12-concurrent-0 via dfcd09965d50...
Getting source from Git repository
Fetching changes with git depth set to 50...
Reinitialized existing Git repository in /builds/zh****/e****/.git/
fatal: unable to access 'http://8.136.221.242:8010/zh****/e****.git/': Failed to connect to 8.136.221.242 port 8010: Operation timed out
ERROR: Job failed: exit code 1
Can anyone help me, thank you so much!
Update your /etc/gitlab/gitlab.rb file and set
external_url "http://172.17.0.3:8010/"
Once you've saved it run
sudo gitlab-ctl reconfigure

exec: "pwsh": executable file not found in %PATH%

I've been trying to initiate my pipeline on gitlab CI/CD for a demo project. I've installed gitlab-runner in my windows local machine and gave the executor type as "Shell". And I've successfully integrated the gitlab-runner with my gitlab project. But whenever I pushed any changes to repo, the pipeline started and end up in "pshw" not found in %PATH error.
This is error which I'm getting every time
ERROR: Job failed (system failure): prepare environment: failed to start process: exec: "pwsh": executable file not found in %PATH%. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information
Can anyone help me to resolve this issue and explain what and why I'm getting this error.
Thanks in advance
When choosing the shell option, the gitlab runner installer uses pwsh as the executor. It generates a config.toml that looks like
[[runners]]
name = "some name"
url = "http://someurl.com/"
token = "some-token"
executor = "shell"
shell = "pwsh"
The problem is that pwsh isn't a valid windows command (on my installs). Changing pwsh to powershell and restarting gitlab-runner service fixed the problem for me.
Go to the installation directory of GitLab Runner e.g. C:\Automation\GitLab-Runner. Here you will see config.toml file, open with notepad and replace "pwsh" with "powershell" as below:
From:
[[runners]]
name = "PT-Runner"
url = "https://gitlab.com"
executor = "shell"
shell = **"pwsh"**
To:
[[runners]]
name = "PT-Runner"
url = "https://gitlab.com"
executor = "shell"
shell = **"powershell"**

How to resolve the docker error" Syntax error: "(" unexpected "

I am new to docker and I am trying to build a docker file for my selenium code (uses gradle)to send it over to devOps for integrating in pipeline . I am able to build the image but when I try running the image i get the following error
"File name too long
/code/executables/chromedriver.exe: 4: /code/executables/chromedriver.exe: Syntax error: "(" unexpected" . Please find the docker file and main class code below
The same code is working fine when i run outside of docker env .
executables is a project folder under which chromedriver.exe is placed
docker file code :
FROM selenium/standalone-chrome
FROM gradle
ADD . /code
WORKDIR /code
CMD gradle build --info
Main java class code where the error i think is originating from :
ChromeOptions chromeOptions = new ChromeOptions();
dc = DesiredCapabilities.chrome();
dc.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
System.setProperty("webdriver.chrome.driver","./executables/chromedriver.exe");
Drivers.driver = new ChromeDriver(dc);
Drivers.driver.get("https://www.facebook.com");