gitlab-plugin
gitlab-plugin copied to clipboard
No credentials found for credentialsId
Issue
Context
- Gitlab plugin version: 1.5.13
- Gitlab version: 12.3.5 (2417d5becc7)
- Jenkins version: 2.190.1
- Job type: Freestyle
Logs & Traces
17:16:32 ERROR: Build step failed with exception
17:16:32 java.lang.IllegalStateException: No credentials found for credentialsId:
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnection.getApiToken(GitLabConnection.java:134)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnection.getClient(GitLabConnection.java:116)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig.getClient(GitLabConnectionConfig.java:92)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:37)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:45)
17:16:32 at com.dabsquared.gitlabjenkins.publisher.MergeRequestNotifier.perform(MergeRequestNotifier.java:31)
17:16:32 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
17:16:32 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
17:16:32 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
17:16:32 at hudson.model.Build$BuildExecution.post2(Build.java:186)
17:16:32 at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
17:16:32 at hudson.model.Run.execute(Run.java:1840)
17:16:32 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
17:16:32 at hudson.model.ResourceController.execute(ResourceController.java:97)
17:16:32 at hudson.model.Executor.run(Executor.java:429)
17:16:32 Build step 'Add note with build status on GitLab merge requests' marked build as failure
17:16:32 ERROR: Build step failed with exception
17:16:32 java.lang.IllegalStateException: No credentials found for credentialsId:
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnection.getApiToken(GitLabConnection.java:134)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnection.getClient(GitLabConnection.java:116)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig.getClient(GitLabConnectionConfig.java:92)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:37)
17:16:32 at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:45)
17:16:32 at com.dabsquared.gitlabjenkins.publisher.MergeRequestNotifier.perform(MergeRequestNotifier.java:31)
17:16:32 at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
17:16:32 at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
17:16:32 at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
17:16:32 at hudson.model.Build$BuildExecution.post2(Build.java:186)
17:16:32 at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
17:16:32 at hudson.model.Run.execute(Run.java:1840)
17:16:32 at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
17:16:32 at hudson.model.ResourceController.execute(ResourceController.java:97)
17:16:32 at hudson.model.Executor.run(Executor.java:429)
17:16:32 Build step 'Add vote for build status on GitLab merge requests' marked build as failure
Problem description
I added "Add note with build status on GitLab merge requests" and "Add vote for build status on GitLab merge requests" to my Freestyle Job as Post-build Actions. But when the job gets triggered by a comment in the Merge request I receive the error above. The project itself gets cloned though via the connection and the build itself is executed. Am I missing anything here or is that a bug?
This happened to me as well. Upon inspecting the job's config.xml file in Jenkins, I found that the following lines were added for some reason.
<jobCredentialId/>
<useAlternativeCredential>false</useAlternativeCredential>
See below for the location in the config file.
<com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="[email protected]">
<gitLabConnection>GitLab</gitLabConnection>
<jobCredentialId/>
<useAlternativeCredential>false</useAlternativeCredential>
</com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>
Manually deleting both lines and restarting Jenkins solved the problem for me. I think the culprit is the empty jobCredentialId field. Another potential solution to this problem is changing the job config to use alternative credentials for GitLab and then selecting the main credentials that were already setup. In doing so, the jobCredentialId changes from <jobCredentialId/>
to <jobCredentialId>redacted</jobCredentialId>
.
Next up is to track down why this is happening and fix it.
same error , delete same code to fix
Run into this myself as well
Ran into this issue today as well. I run two jenkins environments. While the problem was only experienced in one of them, the config above existed in both environments. The environment where i experienced the problem is running jenkins 2.284 & gitlab plugin 1.5.19. The environment which did not have an issue is running jenkins 2.277.1 (stable) & gitlab plugin 1.5.19.
The troubled environment was just patched to 2.284 yesterday.
Ditto, just had to manually edit jobs/*/config.xml and remove those two lines in order to restore webhook functionality. Jenkins 2.287 Gitlab Plugin 1.5.20
Same issue and solution.
Jenkins 2.287 GitLab Plugin 1.5.20
Same issue and solution.
Jenkins 2.249,3 GitLab Plugin 1.5.20
I have two jobs. Both with the same xml settings. One working, one not. The fix worked fine on the one that wasn't working. Very odd!
Good! Same issue and solution.
Jenkins 2.291 GitLab Plugin 1.5.20
Same issue here. Started when upgrading to Jenkins 2.277.3 from 2.266.something. I can go check the exact version from which I upgraded from.
Same issue. Jenkins 2.277.4, GitLab Plugin 1.5.20
Thanks, Same issue and solved. Jenkins 2.277.4, GitLab Plugin 1.5.20
Got bit by this today after upgrading to the latest jenkins core + latest gitlab plugin.
Jenkins 2.293 gitlab-plugin: 1.5.20
Just happened to me, provided solution worked. I needed to apply solution to all existing jobs in jenkins, applying just to the one I was testing did not work.
Thanks! This helped a lot!
Since you mentioned the <useAlternativeCredential>false</useAlternativeCredential>
setting, I decided to give the UI another try. In my case, I was able to check 'Use alternative credential' and then selected the same "Gitlab API Key" I already had choosen globally in the plugin section of the "Configure System" page. This worked for me without modifying the config file.
Dashboard -> Select Job -> Configure -> Use alternative credential -> Select Key
Same issue, same workaround, thx!
Jenkins 2.300 Gitlab Plugin 1.5.20
Also had this issue
Jenkins 2.277.2 Gitlab 1.5.20
Also had this Issue Jenkins 2.289.3 Gitlab 1.5.20
I had the same issue, but didn't have possibility to edit config.xml in filesystem.
I have found that this can be also edited in GUI also:
- select job detail
- click "Use alternative credential" just below Gitlab connection dropdown
- select valid Gitlab API key
Same problem and same solution. Jenkins 2.303.1 Gitlab 13.11.2
Here is how to do it in pipeline : properties([gitLabConnection(gitLabConnection: 'Gitlab Forge', jobCredentialId: '8ec138a7-465e-41ec-8281-e930d0ad4505', useAlternativeCredential: true)])