Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't submit build status: No GitLab connection configured #411

Closed
sturmf opened this issue Sep 12, 2016 · 17 comments
Closed

Can't submit build status: No GitLab connection configured #411

sturmf opened this issue Sep 12, 2016 · 17 comments

Comments

@sturmf
Copy link

sturmf commented Sep 12, 2016

Issue

I try to send the build status from Jenkins back to GitLab but it always only prints: "No GitLab connection configured" in the Jobs console output. Triggering the build automatically works fine and also if I go into the Jenkins configuration under the topic GitLab I can press "Test connection" and I get success.

The first line of my Jenkinsfile looks like this:

properties: [[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab']]

Context

  • Gitlab plugin version: 1.4.0
  • Gitlab version: 8.11.5 CE
  • Jenkins version: 2.7.4

Logs & Traces

The GitLab log does not show anything for the submit step, only the trigger event of the build is logged.

Problem description

  1. Commit change to repository and push to GitLab
  2. Watch a new job getting started automatically
  3. Expect a commit status to be pushed to GitLab instead getting "No GitLab connection configured"

Anything else I could try or provide for further assistance?

@coder-hugo
Copy link
Contributor

I bet the value of gitLabConnection doesn't match with the name of your GitLab connection configured in the global Jenkins configuration. Can you please verify that the name of your configured GitLab connection is exactly the one (case sensitive) used in the properties ... line.

@sturmf
Copy link
Author

sturmf commented Sep 12, 2016

Thanks for this idea, I should have mentioned this in my initial writeup. I checked this several times, also played with different apostrophes in the Jenkinsfile. The names really should match. Used copy paste to make sure of that...
If I would know how I can replace the plugin code I would have added print statements around the getClient call. One to print the name and one to print all available gitlab configs and see where it goes wrong.

@coder-hugo
Copy link
Contributor

I think I see the issue. The README was adapted due to this issue #409. But the change is wrong.
properties: ... doesn't call the properties workflow step and so your GitLabConnectionProperty isn't set at all for your job.
Can you please try the following line:
properties [[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab']]
Note the absence of the colon after properties.

@omehegan
Copy link
Member

@coder-hugo I just saw your comment, and since I made that README change, I went and changed my test Jenkinsfile to remove the colon. But the build now fails:

groovy.lang.MissingPropertyException: No such property: properties for class: groovy.lang.Binding

I think the colon is required...

@coder-hugo
Copy link
Contributor

@omehegan nope this colon makes the value properties just a label for the following code block and does not invoke the properties workflow step. So you have to use either the syntax that was described previously in the readme or the one of my last comment. If the last version doesn't work for you just add parantheses around the argument of the step or update your Jenkins Pipeline Plugins.

@sturmf
Copy link
Author

sturmf commented Sep 13, 2016

@coder-hugo

I now tried your syntax as described in you last comment.

properties [[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab']]

I don't have a workflow plugin I think it was replaced by pipeline which is at version 2.3 and pipeline groovy is at 2.15.
And now I get the following exception:

groovy.lang.MissingPropertyException: No such property: properties for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:224)
at org.kohsuke.groovy.sandbox.impl.Checker$4.call(Checker.java:241)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:238)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:24)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:1)

I then restored the setting to the original from the Readme:

properties properties: [[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab']]

And I now get:

java.lang.UnsupportedOperationException: must specify $class with an implementation of interface java.util.List
at org.jenkinsci.plugins.structs.describable.DescribableModel.resolveClass(DescribableModel.java:442)
at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:371)
at org.jenkinsci.plugins.structs.describable.DescribableModel.buildArguments(DescribableModel.java:313)

I then did one last try, after googling more and it seems the following line is working!:

properties([[$class: 'GitLabConnectionProperty', gitLabConnection: 'entropy']])

Now the plugin seems to have a connection and tries to push commit status. Unfortunately this now throws errors but I probably should open another issue if I can't find a fix for this.

[Pipeline] gitlabCommitStatus
[Pipeline] {
Failed to update Gitlab commit status for project 'testproj/test': java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Illegal character ((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed between tokens
at [Source: �������N�0��_��JZ��؎311����:�N�H�d_$������
��������;��E/�������_5�������u�s��Z��D%�����[�4�~h�_�ǐ>b_c�M%p%n�����@�1�h�����㴵�3�����!����HLj�z�v/�g���A������j����������sH�t��p�Qmc�킒�Z��y�Mk�A#-��Y��xc�e�#m��en������BHlu��}��$�d%|��u����S_��_9��i�|�7�uӾ�; line: 1, column: 2]

@omehegan
Copy link
Member

Sounds like there was a change to the Pipeline plugin which requires different syntax for this. We should isolate that and call it out in the documentation. I'm pretty confused now about what this is doing and why different syntaxes work or don't work.

@algorys
Copy link

algorys commented Sep 19, 2016

The same problem appears to me:

  • Gitlab 8.1
  • Gitlab plugin 1.4.0
  • jenkins 2.7.4

I've try many syntax (post here and other website) in my pipeline, but anyway, nothing is send to Gitlab...

When I push, Gitlab trigger the job, jenkins do the job, but always No GitLab connection configured.

Question : does Gitlab runner is required to make it works ?

@Camsteack
Copy link

I had the exact same issue but it is fixed after updating all the Pipeline plugins to the very last version with the syntax :

properties properties: [[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab-connection']]

@algorys
Copy link

algorys commented Sep 30, 2016

Works with last version (1.4.2), and syntax of @Camsteack . But I still do not have my builds in Builds Gitlab page. Only available in Commits Gitlab page.

@omehegan
Copy link
Member

@coder-hugo from talking to jglick, it seems like this syntax is most universally correct:

properties([[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab']])

When I use
properties properties: [[$class: 'GitLabConnectionProperty', gitLabConnection: 'gitlab']]

I get the same error that @sturmf did:
java.lang.UnsupportedOperationException: must specify $class with an implementation of interface java.util.List

@omehegan
Copy link
Member

omehegan commented Nov 2, 2016

Updated README.

@omehegan omehegan closed this as completed Nov 2, 2016
@LucasHild
Copy link

I still get the same error message: "No GitLab connection configured".

I found this error in the Jenkins log:

Error while serving http://app/descriptorByName/com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig/testConnection
java.lang.IllegalStateException: No credentials found for credentialsId: 
	at com.dabsquared.gitlabjenkins.connection.GitLabConnection.getApiToken(GitLabConnection.java:134)
	at com.dabsquared.gitlabjenkins.connection.GitLabConnection.getClient(GitLabConnection.java:116)
	at com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig.doTestConnection(GitLabConnectionConfig.java:141)
	at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:627)
	at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:396)
Caused: java.lang.reflect.InvocationTargetException

If I click on "Test Connection" in the System Configuration, the status is successful, but I get the error message "API Token for Gitlab access required"

Screenshot_2019-04-17 Configure System  Jenkins

One weird thing is that the credential has no usage according to the credential page.

Screenshot_2019-04-17 System » Global credentials (unrestricted) » GitLab API token (lanseuo gitlab com)  Jenkins

But the right token id is stored in GitLabConnectionConfig.xml:

$ cat com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig.xml 
<?xml version='1.1' encoding='UTF-8'?>
<com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig plugin="gitlab-plugin@1.5.11">
  <useAuthenticatedEndpoint>true</useAuthenticatedEndpoint>
  <connections>
    <com.dabsquared.gitlabjenkins.connection.GitLabConnection>
      <name>GitLab.com</name>
      <url>https://gitlab.com</url>
      <apiTokenId>lanseuo-gitlab-token</apiTokenId>
      <clientBuilder class="com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectGitLabClientBuilder">
        <id>autodetect</id>
        <ordinal>0</ordinal>
      </clientBuilder>
      <ignoreCertificateErrors>false</ignoreCertificateErrors>
      <connectionTimeout>10</connectionTimeout>
      <readTimeout>10</readTimeout>
    </com.dabsquared.gitlabjenkins.connection.GitLabConnection>
  </connections>
</com.dabsquared.gitlabj

@omehegan @sturmf

@galek
Copy link

galek commented Nov 15, 2020

Hello, some issue.

The latest versions of Jenkins and GitLab have used.

@jasonlll88
Copy link

Same issue here

@builder-main
Copy link

For people using freestyle jobs maybe check that you've updated the job configuration afterward ? (this diff is form inheritance plugin)

However I now get a 500 when triggering the build. Maybe the configuration is somehow incorrect ? jobCredentialId missing ?

  <com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty plugin="gitlab-plugin@1.5.20">
-          <gitLabConnection></gitLabConnection>
+          <gitLabConnection>Gitlab-CI</gitLabConnection>
           <jobCredentialId></jobCredentialId>
           <useAlternativeCredential>false</useAlternativeCredential>
         </com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>

@builder-main
Copy link

Confirmed issue and fix for me in the #1119 issue,
Best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants