GitLab Runner Unable to clone repository - continuous-integration

I have registred gitlab runner to the gitlab instance. My registered URL is as follows: http://azurestackgitlab1.southeastasia.cloudapp.azure.com/ci
However while running the build for that project; build is getting failed and giving the below message:
Running with gitlab-ci-multi-runner 1.11.1 (a67a225)
on java test (96d320b3)
WARNING: image is not supported by selected executor and shell
Using Shell executor...
Running on AzureStackPOCVM...
Cloning repository...
Cloning into '/home/gitlab-runner/builds/96d320b3/0/root/demoproject'...
fatal: unable to access 'http://gitlab-ci-token:xxxxxx#gitlab-ce.hxakzvpf0otezeojz3wqhme5wg.cx.internal.cloudapp.net/root/demoproject.git/': Could not resolve host: gitlab-ce.hxakzvpf0otezeojz3wqhme5wg.cx.internal.cloudapp.net
ERROR: Job failed: exit status 1
snippet of config.toml:
[[runners]]
name = "java test"
url = "http://azurestackgitlab1.southeastasia.cloudapp.azure.com/ci"
token = "96d320b33d3c69d706dad7f90df84e"
executor = "shell"
[runners.cache]
How to overcome this problem?

You will get this URL mentioned in etc/gitlab/gitlab.rb file. If you will change "hxakzvpf0otezeojz3wqhme5wg.cx.internal.cloudapp.net"
with your "http://azurestackgitlab1.southeastasia.cloudapp.azure.com"
It should work!
For more information you can refer : http://azurestackgitlab1.southeastasia.cloudapp.azure.com/help/administration/environment_variables.md

Related

gitlab runner with 2 workers: 1st worker (BE) fine, 2nd worker (FE) uses docker instead of shell

Firstly I set up 1 worker for 1 job. Deploying my backend for the API.
I'm using "shell" as the executer. The .toml file is this structure:
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Gitlab Runner Josere Backend"
url = "https://gitlab.com/"
token = "sOmEtOkeN1G0Tfr0mGitlab"
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[some mumbo jumbo about caching.. does it matter?]
With some struggle I got that to work fine with this .gitlab-ci.yml:
deploy-production:
stage: deploy
variables:
GIT_STRATEGY: clone
script:
- cd ./lumen/
- composer install
- sudo cp -r $CI_PROJECT_DIR/lumen/. /home/josere/public_html/api/
- sudo cp /home/josere/env/.env /home/josere/public_html/api
This is the execution output of the runner:
Running with gitlab-runner 15.2.1 (32fc1585)
on Gitlab Runner Josere backend 9JxGrMLz
Preparing the "shell" executor
00:00
Using Shell executor...
Preparing environment
00:00
Running on ####[my server]#####...
Getting source from Git repository
00:03
Fetching changes with git depth set to 50...
Initialized empty Git repository in /home/gitlab-runner/builds/9JxGrMLz/0/paspalas/josere/.git/
Created fresh repository.
... etc ...
In my frontend repo in Gitlab I went to the same runners settings. I can't really install a runner (its allready running I guess) but I can copy the token that is shown there.
Then I changed my .toml file according to this doc from gitlab (https://docs.gitlab.com/runner/fleet_scaling/):
concurrent = 2
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "Gitlab Runner Josere Backend"
url = "https://gitlab.com/"
token = "sOmEtOkeN1G0Tfr0mGitlab"
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[some mumbo jumbo about caching.. does it matter?]
[[runners]]
name = "Gitlab Runner Josere Frontend"
url = "https://gitlab.com/"
token = "TheOtherTokenThatIgotFromFrontendRepo!"
executor = "shell"
[runners.custom_build_dir]
[runners.cache]
[some mumbo jumbo about caching.. does it matter?]
notice I do keep the executor on "shell".
this is the script for .gitlab-ci.yml that goes in the root of the frontend repo:
deploy-production:
stage: deploy
variables:
GIT_STRATEGY: clone
script:
- npm install
- npm run build
- sudo cp -r $CI_PROJECT_DIR/public/. /home/josere/public_html/
But when I commit my frontend and check the (failing) log for the worker it writes this:
Running with gitlab-runner 15.4.0~beta.5.gdefc7017 (defc7017)
on green-1.shared.runners-manager.gitlab.com/default JLgUopmM
Preparing the "docker+machine" executor
00:06
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:27d###mumbojumbo###2383b for ruby:2.5 with digest ruby#sha256:ecc3###mumbojumbo###444b ...
Preparing environment
00:00
Running on runner-jlguopmm-project-39467125-concurrent-0 via runner-jlguopmm-shared-1665674167-6adf45bf...
Getting source from Git repository
00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/paspalas/josere-frontend/.git/
Created fresh repository.
Checking out c39e641c as materialui...
Skipping Git submodules setup
Executing "step_script" stage of the job script
00:01
Using docker image sha256:27d###mumbojumbo###3b for ruby:2.5 with digest ruby#sha256:ecc3e###mumbojumbo####44b ...
$ sudo npm install
/bin/bash: line 126: sudo: command not found
Cleaning up project directory and file based variables
00:01
ERROR: Job failed: exit code 1
clearly it seems multiple things go wrong, to start with: why is it using docker while I explicitly tell it to be "shell"?
I fixed the issue. Even though the docs of GitLab differentiates between "runner" and "job", the gitlab-runner calls these "registrations" of a "runner". I did the (extra) registeration like so:
- gitlab-runner register
[filling in info]
- nano /etc/gitlab-runner/config.toml
[check if you have the additional runner]
- gitlab-runner run
[according to gitlab-runner help this is to fire up multiple runners]
- gitlab-runner list
[ now you can check if all "runners" (jobs) are running]

How to push a docker image to remote registry with gradle in a spring boot project

I want to use that ./gradlew bootBuildImage comman to build a docker Image.
That command works perfectaly on my localmachine.
I have a remote docker registry on my server, and I want to push my Images from my local machine directly into my registry using bootBuildImage
To achieve that I added this into my build gradle.
tasks.named("bootBuildImage") {
docker {
builderRegistry {
username = "admin"
password = "secret-password"
url = "https://registry.myserver.com"
}
}
}
On ./gradlew bootBuildImage
I got this Error:
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':bootBuildImage'.
Docker API call to 'localhost/v1.24/images/create?fromImage=docker.io%2Fpaketobuildpacks%2Fbuilder%3Abase'
failed with status code 500 "Internal Server Error" and message "Head
"https://registry-1.docker.io/v2/paketobuildpacks/builder/manifests/base":
una uthorized: incorrect username or password"
Username & Password are 100% correct.
Probably it should be publishRegistry { ... }, not builderRegistry

Gitlab runner upload artifact timeout

I have GitLab runner installed on a MacOS using homebrew. The runner configuration is located under ${HOME}/.gitlab-runner/config.toml and service configuration located under ${HOME}/Library/LaunchAgents/homebrew.mxcl.gitlab-runner.plist is the default.
Below is my gitlab-runner toml configuration file.
concurrent = 1
check_interval = 0
[session_server]
session_timeout = 1800
[[runners]]
name = "MY_RUNNER_NAME"
url = "https://gitlab.com/"
token = "MY_GITLAB_TOKEN"
executor = "shell"
shell = "bash"
environment = ["PATH=/usr/local/opt/openjdk#8/bin:/usr/local/opt/ruby#2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin", "LC_ALL=en_US.UTF-8", "LANG=en_US.UTF-8"]
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.cache.azure]
The runner is connected correctly to Gitlab.com, it executes the steps correctly, but it got stuck in the Uploading artifacts step until the build times out.
Below is my Uploading artifacts logs.
Uploading artifacts...
Runtime platform arch=amd64 os=darwin pid=16690 revision=775dd39d version=13.8.0
android/app/build/outputs/bundle/release/app-release.aab: found 1 matching files and directories
ERROR: Job failed: execution took longer than 1h0m0s seconds
As a debugging step, I tried to run the gitlab-runner artifacts-uploader locally to trace the behavior using this command gitlab-runner --debug --log-level debug artifacts-uploader --verbose --id MY_BUILD_ID --token MY_GITLAB_TOKEN --url https://gitlab.com/ --path android/app/build/outputs/bundle/release/app-release.aab --expire-in "1 week".
Below is my gitlab-runner artifacts-uploader logs.
Runtime platform arch=amd64 os=darwin pid=25259 revision=775dd39d version=13.8.0
android/app/build/outputs/bundle/release/app-release.aab: found 1 matching files and directories
Dialing: tcp gitlab.com:443 ...
It is obvious that the gitlab-runner artifacts-uploader got stuck connecting to gitlab.com:443, and now I am out of ideas on how to trace or solve this issue.

SSH-deployer fails with auth fail error message - Teamcity for scp?

I have a build in Teamcity with the SSH-deployer, but it fails with Auth fail. I am using password authentication, don't wanna use private/public key authentication as it won't be robust approach for us.
Idea is to authenticate via user name and password.
Attached the screenshot for the configuration.
Thanks
Error message:
[06:16:14]Collecting changes in 1 VCS root
[06:16:14][Collecting changes in 1 VCS root] VCS Root details
[06:16:14][VCS Root details] "DE_Automation" {instance id=40631, parent internal id=7496, parent id=Abc_DeAutomation, description: "ssh://git#<server_name>/abc/puppet.git#refs/heads/master"}
[06:16:15]Clearing temporary directory: /opt/teamcity/temp/buildTmp
[06:16:15]Publishing internal artifacts
[06:16:15][Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[06:16:15][Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[06:16:15]Checkout directory: /opt/teamcity/work/376a4e836d9c66e4
[06:16:15]Updating sources: server side checkout
[06:16:15][Updating sources] Using vcs information from agent file: 376a4e836d9c66e4.xml
[06:16:16][Updating sources] Building incremental patch for VCS root: DE_Automation; checkout rules: =>; revision: d88b7e07953108a1a4c392887c28e9b97ce31a5b --> d88b7e07953108a1a4c392887c28e9b97ce31a5b
[06:16:16][Updating sources] Repository sources transferred
[06:16:16]Step 1/3: Command Line
[06:16:16][Step 1/3] Disabled build step Command Line is skipped
[06:16:16]Step 2/3: SFTP (FTP Deployer)
[06:16:16][Step 2/3] Disabled build step SFTP (FTP Deployer) is skipped
[06:16:16]Step 3/3: SCP (SSH Deployer)
[06:16:16][Step 3/3] com.jcraft.jsch.JSchException: Auth fail
[06:16:16]
[Step 3/3] com.jcraft.jsch.JSchException: Auth fail
at com.jcraft.jsch.Session.connect(Session.java:512)
at com.jcraft.jsch.Session.connect(Session.java:183)
at jetbrains.buildServer.deployer.agent.ssh.SSHSessionProvider.<init>(SSHSessionProvider.java:102)
at jetbrains.buildServer.deployer.agent.ssh.SSHDeployerRunner.getDeployerProcess(SSHDeployerRunner.java:44)
at jetbrains.buildServer.deployer.agent.base.BaseDeployerRunner.createBuildProcess(BaseDeployerRunner.java:47)
at jetbrains.buildServer.agent.impl.runner.CallRunnerService.doCreateBuildProcess(CallRunnerService.java:71)
at jetbrains.buildServer.agent.impl.runner.CallRunnerService.createBuildProcess(CallRunnerService.java:47)
at jetbrains.buildServer.agent.impl.buildStages.runnerStages.start.CallRunnerStage.doBuildStage(CallRunnerStage.java:47)
at jetbrains.buildServer.agent.impl.buildStages.RunnerStagesExecutor$1.callStage(RunnerStagesExecutor.java:25)
at jetbrains.buildServer.agent.impl.buildStages.RunnerStagesExecutor$1.callStage(RunnerStagesExecutor.java:18)
at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.callRunStage(StagesExecutor.java:78)
at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.doStages(StagesExecutor.java:37)
at jetbrains.buildServer.agent.impl.buildStages.RunnerStagesExecutor.doStages(RunnerStagesExecutor.java:18)
at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.RunnerContextExecutor.callRunnerStages(RunnerContextExecutor.java:43)
at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.StepExecutor.processNextStep(StepExecutor.java:25)
at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.executeRunnerStep(ForEachBuildRunnerStage.java:138)
at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.runStep(ForEachBuildRunnerStage.java:123)
at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.executeBuildRunners(ForEachBuildRunnerStage.java:83)
at jetbrains.buildServer.agent.impl.buildStages.startStages.steps.ForEachBuildRunnerStage.doBuildStage(ForEachBuildRunnerStage.java:44)
at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:31)
at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor$1.callStage(BuildStagesExecutor.java:24)
at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.callRunStage(StagesExecutor.java:78)
at jetbrains.buildServer.agent.impl.buildStages.StagesExecutor.doStages(StagesExecutor.java:37)
at jetbrains.buildServer.agent.impl.buildStages.BuildStagesExecutor.doStages(BuildStagesExecutor.java:24)
at jetbrains.buildServer.agent.impl.BuildRunActionImpl.doStages(BuildRunActionImpl.java:70)
at jetbrains.buildServer.agent.impl.BuildRunActionImpl.runBuild(BuildRunActionImpl.java:50)
at jetbrains.buildServer.agent.impl.BuildAgentImpl.doActualBuild(BuildAgentImpl.java:288)
at jetbrains.buildServer.agent.impl.BuildAgentImpl.access$100(BuildAgentImpl.java:53)
at jetbrains.buildServer.agent.impl.BuildAgentImpl$1.run(BuildAgentImpl.java:252)
at java.lang.Thread.run(Thread.java:748)
[06:16:16][Step 3/3] Step SCP (SSH Deployer) failed with unexpected error
[06:16:16]Publishing internal artifacts
[06:16:16][Publishing internal artifacts] Publishing 1 file using [WebPublisher]
[06:16:16][Publishing internal artifacts] Publishing 1 file using [ArtifactsCachePublisher]
[06:16:16]Build finished
In my case, the problem was not related to SCP (even when TC was saying it is) at all:
My steps:
compile
SCP deploy
some cleanup
shh script on remote server
And step 2 was failing with the same error message as you (but when i SSH to remote server, the file was here)
But, the problem was not in failing step #2 but two steps ahead - i had wrong user in step #4!
Looks like some sort of async bug.

Gradle Docker plugin broken pipe on osx

Hi I try to use this awesome Gradle plugin: https://github.com/bmuschko/gradle-docker-plugin
I use the following URL obtained from my docker-machine / kitematic installation on osx:
docker-machine url default
tcp://192.168.99.100:2376
However using:
url = "tcp://192.168.99.100:2376"
results in the error:
org.apache.http.conn.UnsupportedSchemeException: tcp protocol is not supported
When I change the tcp to httpI get a different error:
INFO org.apache.http.impl.execchain.RetryExec - I/O exception (java.net.SocketException) caught when processing request: Broken pipe
[pool-4-thread-1] ERROR com.github.dockerjava.core.async.ResultCallbackTemplate - Error during callback
org.apache.http.client.ClientProtocolException
in case the gradle dockerBuildImage task is run.
But manually building the Dockerfile created by gradle works without any problems.
The following code can be used to replicate the problem. https://github.com/geoHeil/lab04/blob/master/build.gradle
Docker-machine enables TLS by default. I Switching to the TLSmode should be a good solution:
url = 'https://192.168.59.103:2376'
certPath = new File(System.properties['user.home'], '.boot2docker/certs/boot2docker-vm')

Resources