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']]
The GitLab log does not show anything for the submit step, only the trigger event of the build is logged.
Anything else I could try or provide for further assistance?
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.
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.
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.
@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...
@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.
@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�Hd_$�����
��������;��E/�������_5���u�s�Z�D%�����[�4~h�_�ǐ>b_c�M%p%n�@1�h���㴵�3����!���HLj�zv/�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]
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.
The same problem appears to me:
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 ?
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']]
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.
@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
Updated README.
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"

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

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="[email protected]">
<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
Hello, some issue.
The latest versions of Jenkins and GitLab have used.
Same issue here
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="[email protected]">
- <gitLabConnection></gitLabConnection>
+ <gitLabConnection>Gitlab-CI</gitLabConnection>
<jobCredentialId></jobCredentialId>
<useAlternativeCredential>false</useAlternativeCredential>
</com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty>
Confirmed issue and fix for me in the #1119 issue,
Best
Most helpful comment
I still get the same error message: "No GitLab connection configured".
I found this error in the Jenkins log:
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"
One weird thing is that the credential has no usage according to the credential page.
But the right token id is stored in
GitLabConnectionConfig.xml:@omehegan @sturmf