sonar-gitlab-plugin icon indicating copy to clipboard operation
sonar-gitlab-plugin copied to clipboard

FileNotFoundException on Gitlab 8.0.5

Open alwa opened this issue 7 years ago • 14 comments

Hi, the plugin is working for me but I'm getting these errors in the build log (see below). This is the "sonarqube_preview" step.

My setup: Gitlab version 8.0.5 Gitlab CI multi runner version 1.11.5 SonarQube version 5.6.6 LTS SonarQube Scanner version 3.0.3.778

Any idea what could cause this? The referenced gitlab user (through the user token) has the developer role for the namespace.

...
INFO: SonarQube server 5.6.6
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=133ms
INFO: GlobalWorkingDir null
INFO: Execute project builders
INFO: Execute project builders (done) | time=547ms
ERROR: Unable to update commit status
java.io.FileNotFoundException: https://MYSERVER_ADDRESS/api/v3/projects/82/statuses/4fcc071c092f59578ff4ac0a9a847a6fdcf76b7d
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1872) ~[na:1.8.0_131]
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474) ~[na:1.8.0_131]
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254) ~[na:1.8.0_131]
	at com.talanlabs.gitlab.api.v3.http.GitLabHTTPRequestor.parse(GitLabHTTPRequestor.java:336) ~[java-gitlab-api-1.3.0.jar:na]
	at com.talanlabs.gitlab.api.v3.http.GitLabHTTPRequestor.to(GitLabHTTPRequestor.java:123) ~[java-gitlab-api-1.3.0.jar:na]
	at com.talanlabs.gitlab.api.v3.http.GitLabHTTPRequestor.to(GitLabHTTPRequestor.java:95) ~[java-gitlab-api-1.3.0.jar:na]
	at com.talanlabs.gitlab.api.v3.services.GitLabAPICommits.postCommitStatus(GitLabAPICommits.java:181) ~[java-gitlab-api-1.3.0.jar:na]
	at com.talanlabs.sonar.plugins.gitlab.GitLabApiV3Wrapper.createOrUpdateSonarQubeStatus(GitLabApiV3Wrapper.java:211) ~[sonar-gitlab-plugin-2.1.0.jar:na]
	at com.talanlabs.sonar.plugins.gitlab.CommitFacade.createOrUpdateSonarQubeStatus(CommitFacade.java:103) [sonar-gitlab-plugin-2.1.0.jar:na]
	at com.talanlabs.sonar.plugins.gitlab.CommitProjectBuilder.build(CommitProjectBuilder.java:56) [sonar-gitlab-plugin-2.1.0.jar:na]
	at org.sonar.batch.scan.ProjectBuildersExecutor.execute(ProjectBuildersExecutor.java:49) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.batch.scan.ImmutableProjectReactorProvider.provide(ImmutableProjectReactorProvider.java:32) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
	at org.picocontainer.injectors.MethodInjector.invokeMethod(MethodInjector.java:129) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.MethodInjector.access$000(MethodInjector.java:39) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:113) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:67) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.DefaultPicoContainer.instantiateComponentAsIsStartable(DefaultPicoContainer.java:1034) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.DefaultPicoContainer.addAdapterIfStartable(DefaultPicoContainer.java:1026) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1003) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:141) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.batch.task.ScanTask.execute(ScanTask.java:47) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.batch.task.TaskContainer.doAfterStart(TaskContainer.java:86) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:142) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:127) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:106) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:119) [sonar-scanner-engine-shaded-5.6.6.jar:na]
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63) [sonar-scanner-api-batch6407673028187071459.jar:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131]
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60) [sonar-scanner-cli-3.0.3.778.jar:na]
	at com.sun.proxy.$Proxy0.execute(Unknown Source) [na:na]
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:233) [sonar-scanner-cli-3.0.3.778.jar:na]
	at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151) [sonar-scanner-cli-3.0.3.778.jar:na]
	at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123) [sonar-scanner-cli-3.0.3.778.jar:na]
	at org.sonarsource.scanner.cli.Main.execute(Main.java:77) [sonar-scanner-cli-3.0.3.778.jar:na]
	at org.sonarsource.scanner.cli.Main.main(Main.java:61) [sonar-scanner-cli-3.0.3.778.jar:na]

alwa avatar Oct 30 '17 14:10 alwa

What is version this plugin GitLab ?

gabrie-allaigre avatar Oct 30 '17 15:10 gabrie-allaigre

Hi @gabrie-allaigre

it's version 2.1.0 (latest available)

alwa avatar Oct 30 '17 15:10 alwa

Trying it in the web browser does not work either ("leads to not found page") so it looks like the web service does not exist (otherwise I would expect some other error)

alwa avatar Oct 30 '17 15:10 alwa

Hi, try to change sonar.gitlab.failure_notification_mode = exit-code

gabrie-allaigre avatar Oct 30 '17 15:10 gabrie-allaigre

I found a lead. Trying https://MYSERVER_ADDRESS/api/v3/projects/82/ gives me 401 in the browser even if I have the right permissions and am logged in in the browser session. So the project id is of the wrong format perhaps?

Will try your suggestion

alwa avatar Oct 30 '17 15:10 alwa

With your suggestion I'm not seeing any errors at all. Everything looks OK.

alwa avatar Oct 30 '17 15:10 alwa

Weird, I introduced a violation deliberately and now I'm seeing the same error again

alwa avatar Oct 30 '17 15:10 alwa

@gabrie-allaigre

I've done some investigation. The project ID is correct. I was able to retrieve JSON data when I added the private_token query parameter in the browser, e.g: https://MYSERVER_ADDRESS/api/v3/projects/82?private_token=$MY_GITLAB_TOKEN$

When I try https://MYSERVER_ADDRESS/api/v3/projects/82/statuses/4fcc071c092f59578ff4ac0a9a847a6fdcf76b7d?private_token=$MY_GITLAB_TOKEN$ however I get 404 Not Found in my browser.

alwa avatar Nov 01 '17 11:11 alwa

Hi, Your use with private_tokenr, what is access for project 82 ?

gabrie-allaigre avatar Nov 02 '17 08:11 gabrie-allaigre

The role of the user mapped to the private token is "Developer" for project 82

alixwar avatar Nov 02 '17 08:11 alixwar

With sonar.gitlab.failure_notification_mode = exit-code whate is error ?

gabrie-allaigre avatar Nov 02 '17 09:11 gabrie-allaigre

I can only trigger the problem if there is any issue in the merge request (so that the plugin tries to comment the commit) but if there is any new violation the build fails prematurely because of the flag:

:sonarqube FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':sonarqube'.
> Report status=failed, desc=SonarQube reported 9 issues, with 1 critical (fail) and 8 major

alixwar avatar Nov 02 '17 10:11 alixwar

It's normal, sonar.gitlab.failure_notification_mode = exit-code failed CI if a critical issue or blocker issue

gabrie-allaigre avatar Nov 02 '17 10:11 gabrie-allaigre

I have met similar issue, and found that the Commit Status API was added in GitLab 8.1 from the release notes.

GitLab 8.1
Thursday, October 22, 2015

GitLab = GL + CI
Design Updates
Check out Merge Request
Commit Status API
Further improvements
GitLab Mattermost Update

Due to the risk of upgrading GitLab CE in enterprise development environment, @gabrie-allaigre can you fix this to make it compatible with GitLab version below 8.1 ?

Edited, actually I just find it's not bothered for the major function, just log the error.

qtopie avatar Oct 31 '18 07:10 qtopie