Gitlab runner artifacts : 405 Method Not allowed - gitlab

I try to use artifacts on my Gitlab and when my runner try to put my artifact file on Giltlab, i have this message :
WARNING: Uploading artifacts to coordinator... failed id=504 responseStatus=405 Method Not Allowed status=405 Method Not Allowed token=HebbSqMD
WARNING: Retrying...
WARNING: Uploading artifacts to coordinator... failed id=504 responseStatus=405 Method Not Allowed status=405 Method Not Allowed token=HebbSqMD
WARNING: Retrying...
WARNING: Uploading artifacts to coordinator... failed id=504 responseStatus=405 Method Not Allowed status=405 Method Not Allowed token=HebbSqMD
FATAL: invalid argument
ERROR: Job failed: exit code 1
My job is :
build:
stage: build
script:
- echo "Building the app" > out.txt
artifacts:
paths:
- out.txt
Gitlab 8.16 or 8.17 : same probleme
Gitlab runner on other host (docker executor) : 1.11.0 o 1.10.4 : same probleme

Simply, verified artifacts enabled in /etc/gitlab/gitlab.rb file:
## Build Artifacts
# gitlab_rails['artifacts_enabled'] = true
# gitlab_rails['artifacts_path'] = "/mnt/storage/artifacts"

Related

GitLab CI: Issue with SAST IaC uploading artifacts - permission denied

I have an error when using the template for IaC SAST.
Gitlab is 14.10, installed in my cloud, and accessible from the internet (I changed my real GitLab ULR to owngitlab.com)
The GitLab runner is installed in k8s.
Try to use SAST in my projects, but I get errors. Could somebody please help with this?
Here is part of my .gitlab-ci.yml
include:
- template: Security/SAST-IaC.latest.gitlab-ci.yml
stages:
- test
Pipeline log:
$ /analyzer run
[INFO] [kics] [2022-05-20T12:41:44Z] ▶ GitLab kics analyzer v1.5.2
[INFO] [kics] [2022-05-20T12:41:44Z] ▶ Detecting project
[INFO] [kics] [2022-05-20T12:41:44Z] ▶ Found relevant files in project, analyzing entire repository
[INFO] [kics] [2022-05-20T12:41:44Z] ▶ Running analyzer
[INFO] [kics] [2022-05-20T12:41:44Z] ▶ path /builds/tf/modules
[INFO] [kics] [2022-05-20T12:42:43Z] ▶ Creating report
[WARN] [kics] [2022-05-20T12:42:43Z] ▶ Could not detect git executable
Uploading artifacts for successful job
Uploading artifacts...
gl-sast-report.json: found 1 matching files and directories
ERROR: Uploading artifacts as "sast" to coordinator... error error=couldn't execute POST against https://owngitlab.com/api/v4/jobs/139/artifacts?artifact_format=raw&artifact_type=sast: Post "https://owngitlab.com/api/v4/jobs/139/artifacts?artifact_format=raw&artifact_type=sast": open gl-sast-report.json: permission denied id=139 token=hZ5dXhA7
WARNING: Retrying... context=artifacts-uploader error=invalid argument
ERROR: Uploading artifacts as "sast" to coordinator... error error=couldn't execute POST against https://owngitlab.com/api/v4/jobs/139/artifacts?artifact_format=raw&artifact_type=sast: Post "https://owngitlab.com/api/v4/jobs/139/artifacts?artifact_format=raw&artifact_type=sast": open gl-sast-report.json: permission denied id=139 token=hZ5dXhA7
WARNING: Retrying... context=artifacts-uploader error=invalid argument
ERROR: Uploading artifacts as "sast" to coordinator... error error=couldn't execute POST against https://owngitlab.com/api/v4/jobs/139/artifacts?artifact_format=raw&artifact_type=sast: Post "https://owngitlab.com/api/v4/jobs/139/artifacts?artifact_format=raw&artifact_type=sast": open gl-sast-report.json: permission denied id=139 token=hZ5dXhA7
FATAL: invalid argument
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: command terminated with exit code 1

Cache task in AzDO is timing out

My cache task fails with a timeout exception, wasn't able to find any information on the web
2021-11-19T13:12:49.5440178Z ##[section]Starting: Cache Maven local repo
2021-11-19T13:12:49.5444463Z ==============================================================================
2021-11-19T13:12:49.5444700Z Task : Cache
2021-11-19T13:12:49.5444880Z Description : Cache files between runs
2021-11-19T13:12:49.5445073Z Version : 2.0.1
2021-11-19T13:12:49.5445247Z Author : Microsoft Corporation
2021-11-19T13:12:49.5445454Z Help : https://aka.ms/pipeline-caching-docs
2021-11-19T13:12:49.5445913Z ==============================================================================
2021-11-19T13:12:50.3859003Z Resolving key:
2021-11-19T13:12:50.3867990Z - maven [string]
2021-11-19T13:12:50.3868628Z - "Linux" [string]
2021-11-19T13:12:50.3869252Z - **/pom.xml [file pattern; matches: 1]
2021-11-19T13:12:50.3870147Z - s/pom.xml --> 425BE14263A590554133E4A4AE3B095D0207EE19CADB68111111A8623073C9
2021-11-19T13:12:50.3870747Z Resolved to: maven|"Linux"|6BG0VLzocHR1ABXQNLQ+q7oxXHj2Ln9xNBME=
2021-11-19T13:12:50.3872532Z Resolving restore key:
2021-11-19T13:12:50.3873112Z - maven [string]
2021-11-19T13:12:50.3873653Z - "Linux" [string]
2021-11-19T13:12:50.3874064Z Resolved to: maven|"Linux"|**
2021-11-19T13:12:50.3874469Z Resolving restore key:
2021-11-19T13:12:50.3874998Z - maven [string]
2021-11-19T13:12:50.3875403Z Resolved to: maven|**
2021-11-19T13:12:50.4071086Z ApplicationInsightsTelemetrySender will correlate events with X-TFS-Session 018d9b8b-7e2e-4eb4-9081-60a8aac6ca19
2021-11-19T13:12:50.4271999Z Getting a pipeline cache artifact with one of the following fingerprints:
2021-11-19T13:12:50.4272751Z Fingerprint: `maven|"Linux"|6BG0VLzocHR1ABXQNLQ+CkcxTTgq7oxXHj2Ln9xNBME=`
2021-11-19T13:12:50.4273230Z Fingerprint: `maven|"Linux"|**`
2021-11-19T13:12:50.4273649Z Fingerprint: `maven|**`
2021-11-19T13:12:51.4866539Z There is a cache hit: `maven|"Linux"|6BG0VLzocHR1ABXQNLQ+CkcxTTgq7oxXHj2Ln9xNBME=`
2021-11-19T13:12:51.4878034Z Used scope: 1506;0fc5062f-55dd-476b-baba-8952a15401e7;refs/heads/EOD_STORES;52820a17-3ace-4f9e-ba77-2330a6eccacb
2021-11-19T13:12:51.5808454Z Entry found at fingerprint: `maven|"Linux"|6BG0VLzocHR1ABXQNLQ+CkcxTTgq7oxXHj2Ln9xNBME=`
2021-11-19T13:13:51.9289494Z [https://vb8vsblobprodsu6weus46.blob.core.windows.net/db908636dc538642c896c6b0557076a854/1F68E25AD7A9B91792F6DE976146515E90F7488470FD5DB9D2166AEB7C2451A201?sv=2019-07-07&sr=b&spr=https&se=2021-11-20T14:07:21Z&sp=r&rscl=x-e2eid-7f1caaa0-030b4341-adf321f6-8515e4e2-session-018d9b8b-7e2e4eb4-908160a8-aac6ca19] Try 1/5, Task was requested to be canceled.
2021-11-19T13:45:52.9504822Z ApplicationInsightsTelemetrySender correlated 3 events with X-TFS-Session 018d9b8b-7e2e-4eb4-9081-60a8aac6ca19
2021-11-19T13:45:52.9581543Z ##[error]Attempt timed out after 00:01:00.
2021-11-19T13:45:52.9618987Z ##[section]Finishing: Cache Maven local repo

ERROR: Sonar server 'http://localhost:9000' can not be reached in GitLab Pipeline

I'm trying to integrate SonarQube into my CICD pipeline on GitLab but I am getting an error during the sonarqube stage on Gitlab. I followed the documentation for the GitLab integration so this is how my code looks like:
gitlab-ci.yml file:
sonarqube-check:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner -Dsonar.qualitygate.wait=true
allow_failure: true
only:
- sonarqube
In the root folder I have the sonar-project.properties file:
# must be unique in a given SonarQube instance
sonar.projectKey=<name>
# --- optional properties ---
# defaults to project key
sonar.projectName=application with SonarQube
# defaults to 'not provided'
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=src
sonar.host.url=http://127.0.0.1:9000
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
I originally did localhost:9000 for the sonar.host.url but that still produces the following error:
ERROR: SonarQube server [http://127.0.0.1:9000] can not be reached
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 0.741s
ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
INFO: Final Memory: 3M/14M
INFO: ------------------------------------------------------------------------
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
... 7 more
Caused by: java.net.ConnectException: Failed to connect to /127.0.0.1:9000
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:265)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connect(RealConnection.java:183)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ExchangeFinder.find(ExchangeFinder.java:88)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Transmitter.newExchange(Transmitter.java:169)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.getResponseWithInterceptorChain(RealCall.java:221)
at org.sonarsource.scanner.api.internal.shaded.okhttp.RealCall.execute(RealCall.java:81)
at org.sonarsource.scanner.api.internal.ServerConnection.callUrl(ServerConnection.java:115)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:99)
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
... 10 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
at java.base/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.base/java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.base/java.net.SocksSocketImpl.connect(Unknown Source)
at java.base/java.net.Socket.connect(Unknown Source)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.platform.Platform.connectSocket(Platform.java:130)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.RealConnection.connectSocket(RealConnection.java:263)
... 31 more
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
I'm not really sure what to do next for this to work. I also created two environmental variables in GitLab like the documentation says: SONAR_HOST_URL and SONAR_TOKEN but I'm not sure if that does anything. I set SONAR_HOST_URL to localhost:9000 too.... Any guidance or help is greatly appreciated!! I just want to have it so there is a sonarqube check during my CI/CD pipeline in GitLab...

WARNING: Uploading artifacts as "archive" to coordinator... failed id=1515 responseStatus=500 Internal Server Error status=500

I'm using Gitlab self server community version ci/cd function, It has been running well, But suddenly one day,All the projects in the gitlab/cicd has failed, it mentions below errors:
Uploading artifacts for successful job
Uploading artifacts...
promotion-api/my-boot-module-system/target/*.jar: found 1 matching files and directories
WARNING: Uploading artifacts as "archive" to coordinator... failed id=1515 responseStatus=500 Internal Server Error status=500 token=xrDFnLeB
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "archive" to coordinator... failed id=1515 responseStatus=500 Internal Server Error status=500 token=xrDFnLeB
WARNING: Retrying... context=artifacts-uploader error=invalid argument
WARNING: Uploading artifacts as "archive" to coordinator... failed id=1515 responseStatus=500 Internal Server Error status=500 token=xrDFnLeB
FATAL: invalid argument
ERROR: Job failed: exit code 1
Below is the code in .gitlab-ci.yml
deploy-java:
stage: deploy
dependencies:
- build-java
image:
name: docker/compose:latest
before_script:
- docker info
- docker-compose -v
script:
- cd promotion-api
- docker-compose build
- docker images
- docker ps -a
- docker-compose up -d
tags:
- promotion
2021-3-29:
I switched the runner from linux version to docker, seems all fine till now
You ran into a bug in GitLab itself. Instead of a rather obscure HTTP status 500 it should say what the issue is explicitly. It is likely not a problem in your repository or CI settings.
Follow these issues to find out more:
Artifact is stopped in the transfer, possibly because it takes longer than some timeout to upload: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26869
Artifact is larger than 1 GB: https://gitlab.com/gitlab-org/gitlab/-/issues/267111
For me the problem was that gitlab had run out of disk-space.
After having deleted unnecessary artifacts and files everything was working correctly again.
You can check your system status (if you host your own gitlab) here: www.gitlab-url.com/admin/system_info
(Go to: Admin Area > Monitoring > System Info)
Hope it helps!

Gitlab Runner artifacts-downloader returns Forbidden when downloading artifacts

I have a pipeline with 3 jobs. The 2nd job would build docker file and upload.
But the 3rd stage failed with this error.
ERROR: Downloading artifacts from coordinator... error error=unexpected EOF
So I tried to use gitlab-runner artifacts-downloader to download artifacts on the runner machine.
$ sudo gitlab-runner artifacts-downloader --url https://gitlab.com/ --token xxx-xxxx --id 359820234
Runtime platform arch=amd64 os=linux pid=24718 revision=05161b14
version=12.4.1
ERROR: Downloading artifacts from coordinator... forbidden id=359820234 responseStatus=403 Forbidden status=403 Forbidden token=xxx-xxxx
FATAL: permission denied
However, I got the forbidden error. Did I miss anything?

Resources