jenkinsci / gitlab-plugin

A Jenkins plugin for interfacing with GitLab
https://plugins.jenkins.io/gitlab-plugin/
GNU General Public License v2.0
1.44k stars 619 forks source link

Pipeline jobs hang when using gitlabBuilds step #430

Closed criemen closed 7 years ago

criemen commented 8 years ago

Context

Running this simple pipeline job on a slave called max hangs forever: node ('max') { gitlabBuilds(builds: ['Build', 'Prepare Tests', 'Execute Tests']) { println "Hello world" } } with the following log:

Started by user XXX [Pipeline] node Still waiting to schedule task Waiting for next available executor on max Running on max in /home/jenkins/workspace/_Redgiant/cri_test_2 [Pipeline] { [Pipeline] gitlabBuilds [Pipeline] {

omehegan commented 8 years ago

I think your example is expecting stages with the names Build, Prepare Tests, etc. Try adding stage Build before your println step (which in Pipeline can just be 'echo').

criemen commented 8 years ago

Hi, the job even hangs when run on the master (so, my error here). Even without the stages, the job shouldn't just hang.

With the following job, we also hang at gitlabBuilds.

node {
    println "Checking code out in Workspace: ${env.WORKSPACE}"
    stage('Checkout') {
        checkout([$class: 'GitSCM', branches: [[name: 'master']], extensions: [[$class: 'CloneOption', shallow: false], [$class: 'CleanBeforeCheckout']], userRemoteConfigs: [[credentialsId: '64d7fdb8-b948-48cc-8ddf-a17c7fa8e1e9', url: 'git@git.local.itscope.com:itscope/redgiant.git']]])
    }
    gitlabBuilds(builds: ['Build', 'Prepare Tests', 'Execute Tests']) {
        stage('Build') {
        println "Hello world"
        }
    }
}

We get the following exception in jenkins:

Oct 14, 2016 6:11:29 PM org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService reportProblem
WARNING: Unexpected exception in CPS VM thread: CpsFlowExecution[Owner[_Redgiant/cri_test/8:_Redgiant/cri_test #8]]
java.lang.RuntimeException: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:33)
    at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.getProviderFactory(ResteasyClientBuilder.java:339)
    at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.register(ResteasyClientBuilder.java:541)
    at com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder.buildClient(GitLabClientBuilder.java:89)
    at com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder.buildClient(GitLabClientBuilder.java:100)
    at com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig.getClient(GitLabConnectionConfig.java:77)
    at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:35)
    at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:43)
    at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.updateCommitStatus(CommitStatusUpdater.java:35)
    at com.dabsquared.gitlabjenkins.workflow.GitLabBuildsStep$Execution$1.onStart(GitLabBuildsStep.java:72)
    at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.launch(CpsBodyExecution.java:114)
    at org.jenkinsci.plugins.workflow.cps.CpsBodyInvoker.launch(CpsBodyInvoker.java:170)
    at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.invokeBody(DSL.java:499)
    at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.eval(DSL.java:469)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:173)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: RESTEASY003940: Unable to instantiate MessageBodyReader
    at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1405)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1344)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.registerProviders(RegisterBuiltin.java:68)
    at org.jboss.resteasy.plugins.providers.RegisterBuiltin.register(RegisterBuiltin.java:29)
    ... 27 more
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public org.jboss.resteasy.plugins.providers.DocumentProvider(org.jboss.resteasy.spi.ResteasyConfiguration)
    at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:162)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.createProviderInstance(ResteasyProviderFactory.java:2209)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.addMessageBodyReader(ResteasyProviderFactory.java:782)
    at org.jboss.resteasy.spi.ResteasyProviderFactory.registerProvider(ResteasyProviderFactory.java:1400)
    ... 30 more
Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
    at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:311)
    at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267)
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:120)
    at org.jboss.resteasy.plugins.providers.DocumentProvider.<init>(DocumentProvider.java:49)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
    ... 33 more
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
    at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:308)
    ... 41 more
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at javax.xml.parsers.FactoryFinder$1.run(FactoryFinder.java:294)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:289)
    ... 41 more

This exception now started occuring on other (previously working!) jobs. Is there anything we can do about it? Every time this execution occurs we have to stop the job, abort the running step and then forcibly kill the entire job...

omehegan commented 8 years ago

@Corni I can't reproduce the hanging build issue, even with a nearly identical Pipeline script to yours. The exception you're seeing makes me suspect that this could be an issue with one of the Pipeline plugins. Can you try updating those to the latest versions and see if this issue persists?

mpdeimos commented 8 years ago

I'm getting the same error as described above. Here is a small sample script:


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

node {
    checkout scm
    gitlabBuilds(builds: ['stage1']) {
        stage('stage1') {
            gitlabCommitStatus('stage1') {
                sh 'echo Hello'
            }
        }
    }
}

So it hangs like this on console:

Resetting working tree
 > git reset --hard # timeout=10
 > git clean -fdx # timeout=10
[Pipeline] gitlabBuilds
[Pipeline] {

I'm getting the same if omitting the gitlabBuilds, then it hangs on gitlabCommitStatus.

Also I've just updated all Jenkins plugins to latest version and GitLab server (own hosted CE) is up to date at version 8.13.1

mpdeimos commented 8 years ago

After killing some jobs, I got this in the log:

hudson.remoting.ProxyException: com.google.inject.ConfigurationException: Guice configuration errors:

1) Could not find a suitable constructor in com.dabsquared.gitlabjenkins.workflow.GitLabCommitStatusStep. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
  at com.dabsquared.gitlabjenkins.workflow.GitLabCommitStatusStep.class(GitLabCommitStatusStep.java:28)
  while locating com.dabsquared.gitlabjenkins.workflow.GitLabCommitStatusStep
    for field at com.dabsquared.gitlabjenkins.workflow.GitLabCommitStatusStep$Execution.step(GitLabCommitStatusStep.java:46)
  while locating com.dabsquared.gitlabjenkins.workflow.GitLabCommitStatusStep$Execution

1 error
    at com.google.inject.internal.InjectorImpl.getMembersInjector(InjectorImpl.java:981)
    at com.google.inject.internal.InjectorImpl.getMembersInjector(InjectorImpl.java:986)
    at com.google.inject.internal.InjectorImpl.injectMembers(InjectorImpl.java:972)
    at org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl.inject(AbstractStepExecutionImpl.java:38)
    at org.jenkinsci.plugins.workflow.steps.AbstractStepExecutionImpl.onResume(AbstractStepExecutionImpl.java:33)
    at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ItemListenerImpl$1.onSuccess(FlowExecutionList.java:179)
    at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ItemListenerImpl$1.onSuccess(FlowExecutionList.java:174)
    at com.google.common.util.concurrent.Futures$6.run(Futures.java:975)
    at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:253)
    at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:149)
    at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:134)
    at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:170)
    at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$5.onSuccess(CpsFlowExecution.java:712)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$5.onSuccess(CpsFlowExecution.java:690)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution$4$1.run(CpsFlowExecution.java:627)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:35)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Finished: FAILURE

Also I found the exception posted earlier by @Corni in CpsVmExecutorService in the global Jenkins log.

mpdeimos commented 8 years ago

Besides using our on-prem GitLab install, i've now also tried targeting gitlab.com with repo https://gitlab.com/mpdeimos/ci-test/ --> same result: build hangs.

omehegan commented 8 years ago

This is very strange. I think if it were a bug in the plugin itself, we'd be hearing about it much more. So I have to guess it's an issue with Jenkins or another plugin. Or possibly an issue with these most recent versions of GitLab.

What version of Java are you folks running Jenkins in?

Can you look at your GitLab server logs and see if Jenkins is trying to connect at all?

Can you post a longer log from Jenkins, showing the job being triggered etc? Follow the instructions here: https://github.com/jenkinsci/gitlab-plugin#user-support so that we get relevant logging from the plugin.

mpdeimos commented 8 years ago

Jenkins is installed from docker image: https://hub.docker.com/r/jenkinsci/jenkins/

Java: openjdk 8 (102), provided by docker image GitLab: 8.13.1 Jenkins: 2.19.1 GitLab Plugin: 1.4.2 Atm all plugins up to date.

I've configured a logger with finest logging to com.dabsquared.gitlabjenkins, but not logs show when I manually trigger a build. Also configured finest catch-all logger -- nothing interesting.

And gitlab does not seem to receive the request.

I have a feeling that the exception thrown by the resteasy client is related to a classpath issue...

Caused by: javax.xml.parsers.FactoryConfigurationError: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
    at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:311)
    at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:267)
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:120)
    at org.jboss.resteasy.plugins.providers.DocumentProvider.<init>(DocumentProvider.java:49)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
    ... 33 more
Caused by: java.lang.RuntimeException: Provider for class javax.xml.parsers.DocumentBuilderFactory cannot be created
    at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:308)
    ... 41 more
Caused by: java.util.ServiceConfigurationError: javax.xml.parsers.DocumentBuilderFactory: Provider org.apache.xerces.jaxp.DocumentBuilderFactoryImpl not a subtype
    at java.util.ServiceLoader.fail(ServiceLoader.java:239)
    at java.util.ServiceLoader.access$300(ServiceLoader.java:185)
    at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:376)
    at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
    at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
    at javax.xml.parsers.FactoryFinder$1.run(FactoryFinder.java:294)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.xml.parsers.FactoryFinder.findServiceProvider(FactoryFinder.java:289)
    ... 41 more

This is the list and version of Jenkins plugins:

ace-editor  1.1
ant 1.4
antisamy-markup-formatter   1.5
authentication-tokens   1.3
blueocean   1.0.0-b10
blueocean-commons   1.0.0-b10
blueocean-config    1.0.0-b10
blueocean-dashboard 1.0.0-b10
blueocean-events    1.0.0-b10
blueocean-jwt   1.0.0-b10
blueocean-personalization   1.0.0-b10
blueocean-pipeline-api-impl 1.0.0-b10
blueocean-rest  1.0.0-b10
blueocean-rest-impl 1.0.0-b10
blueocean-web   1.0.0-b10
bouncycastle-api    2.16.0
branch-api  1.11
build-timeout   1.17.1
cloudbees-folder    5.13
credentials 2.1.8
credentials-binding 1.9
display-url-api 0.5
docker-commons  1.5
docker-workflow 1.9
durable-task    1.12
email-ext   2.52
external-monitor-job    1.6
favorite    1.16
git 3.0.0
git-client  2.0.0
git-server  1.7
github  1.22.3
github-api  1.79
github-branch-source    1.10
github-organization-folder  1.5
gitlab-plugin   1.4.2
gradle  1.25
handlebars  1.1.1
icon-shim   2.0.3
jackson2-api    2.7.3
jacoco  2.1.0
jquery-detached 1.2.1
junit   1.19
ldap    1.13
mailer  1.18
mapdb-api   1.0.9.0
matrix-auth 1.4
matrix-project  1.7.1
metrics 3.1.2.9
momentjs    1.1.1
pam-auth    1.3
pipeline-build-step 2.3
pipeline-graph-analysis 1.2
pipeline-input-step 2.3
pipeline-milestone-step 1.1
pipeline-model-definition   0.4
pipeline-rest-api   2.1
pipeline-stage-step 2.2
pipeline-stage-view 2.1
plain-credentials   1.3
scm-api 1.3
script-security 1.24
sse-gateway 1.10
ssh-credentials 1.12
ssh-slaves  1.11
structs 1.5
subversion  2.7.1
timestamper 1.8.7
token-macro 2.0
variant 1.0
windows-slaves  1.2
workflow-aggregator 2.4
workflow-api    2.5
workflow-basic-steps    2.2
workflow-cps    2.21
workflow-cps-global-lib 2.4
workflow-durable-task-step  2.5
workflow-job    2.8
workflow-multibranch    2.9
workflow-scm-step   2.2
workflow-step-api   2.4
workflow-support    2.10
ws-cleanup  0.30
milani commented 8 years ago

I have similar issue. My script was working fine. Then I decided to add gitlabCommitStatus {}. To test the pipeline, I manually started the job using "Build Now" button. Now it is in wait queue forever. The script is similar to this:

node('betterspot') {
   gitlabCommitStatus {
       stage('Preparation') { // for display purposes
          notifyBuild('STARTED')
          // Get some code from a GitHub repository
          git url: 'git@gitsource'
       }
       stage('Build HW1') {
           sh "..."
       }
       stage('Build HW2') {
           sh "...."
       }
       stage('Results') {
            notifyBuild(currentBuild.result)
       }
   }
}

def notifyBuild(String buildStatus = 'STARTED') {
  // build status of null means successful
  buildStatus =  buildStatus ?: 'SUCCESSFUL'

  // Default values
  def colorName = 'RED'
  def colorCode = '#FF0000'
  def message = "${env.JOB_NAME} - #${env.BUILD_NUMBER} ${buildStatus} <${env.BUILD_URL}|Open>"

  // Override default values based on build status
  if (buildStatus == 'STARTED') {
    color = 'YELLOW'
    colorCode = '#FFFF00'
  } else if (buildStatus == 'SUCCESSFUL') {
    color = 'GREEN'
    colorCode = '#00FF00'
  } else {
    color = 'RED'
    colorCode = '#FF0000'
  }

  // Send notifications
  slackSend color: color, message: message
}

Jenkins ver. 2.26 Gitlab Plugin 1.2.3

milani commented 8 years ago

The log reads as follows and even aborting the job does not stop it.

Running on MyJob in /var/jenkins/workspace/MyJob
[Pipeline] {
[Pipeline] gitlabCommitStatus
[Pipeline] {
omehegan commented 8 years ago

@milani can you look at the logs on your GitLab server and see if Jenkins is attempting to connect?

pgeorgiev333 commented 8 years ago

Hi,

I see the same issues with:

Git Plugin: 3.0.0 Git client plugin: 2.1.0 Gitlab Auth Plugin : 1.09 Gitlab plugin version: 1.4.3 Gitlab version: GitLab Enterprise Edition 8.12.4-ee Jenkins version: 2.29

criemen commented 8 years ago

This really looks like a classpath issue - for us, the issue went away some time ago, and now that I updated a lot of plugins (including gitlab plugin 1.4.2->1.4.3), the issue resurfaced.

pgeorgiev333 commented 7 years ago

Why closing the issue? It still reproduces in my env?

milani commented 7 years ago

@omehegan I can not afford it. When it happens, I have to restart the whole jenkins system to get it up again and believe me, we have many jobs running.

omehegan commented 7 years ago

I've asked twice for people to check their GitLab server logs to see if there is even an attempt to connect from Jenkins. Can someone please do that and report back? Just look at the GitLab HTTP logs.

mpdeimos commented 7 years ago

https://github.com/jenkinsci/gitlab-plugin/issues/430#issuecomment-257095337

And gitlab does not seem to receive the request.

I have a feeling that the exception thrown by the resteasy client is related to a classpath issue...

Meaning I have not seen anything in the logs, also from the resteasy exception it looks like the request is never send

milani commented 7 years ago

@omehegan I used the same settings as https://github.com/jenkinsci/gitlab-plugin/issues/430#issuecomment-257222900 and here is the log in Jenkins:

WARNING: Unexpected exception in CPS VM thread: CpsFlowExecution[Owner[project-name/82:project-name #82]]
java.lang.IllegalStateException: No credentials found for credentialsId:
    at com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder.getApiToken(GitLabClientBuilder.java:133)
    at com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder.buildClient(GitLabClientBuilder.java:91)
    at com.dabsquared.gitlabjenkins.gitlab.GitLabClientBuilder.buildClient(GitLabClientBuilder.java:101)
    at com.dabsquared.gitlabjenkins.connection.GitLabConnectionConfig.getClient(GitLabConnectionConfig.java:77)
    at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:35)
    at com.dabsquared.gitlabjenkins.connection.GitLabConnectionProperty.getClient(GitLabConnectionProperty.java:43)
    at com.dabsquared.gitlabjenkins.util.CommitStatusUpdater.updateCommitStatus(CommitStatusUpdater.java:35)
    at com.dabsquared.gitlabjenkins.workflow.GitLabCommitStatusStep$Execution$1.onStart(GitLabCommitStatusStep.java:64)
    at org.jenkinsci.plugins.workflow.cps.CpsBodyExecution.launch(CpsBodyExecution.java:122)
    at org.jenkinsci.plugins.workflow.cps.CpsBodyInvoker.launch(CpsBodyInvoker.java:170)
    at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.invokeBody(DSL.java:499)
    at org.jenkinsci.plugins.workflow.cps.DSL$ThreadTaskImpl.eval(DSL.java:469)
    at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:173)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:324)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:78)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:236)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:224)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:63)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:112)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
milani commented 7 years ago

Seems we have multiple issues in this thread. The log above shows I can not send my request to gitlab since credentials are missing. But I don't know how to set credentials when calling gitlabCommitStatus. Obviously, I use the credentials to clone the repo!

milani commented 7 years ago

I managed to fix the issue by setting secret token in jenkins global configuration. I think there should be check that fails when token is not set instead of hanging the whole jenkins.

pgeorgiev333 commented 7 years ago

I do not manage the gitlab server and i do not have access to the logs. I have the secret token setup from the start ( i read the manual...).

I just tried the flow with a Freestyle job and it works.

Standalone pipeline also works. However i noticed something in the "properties" snippet generator:

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

This does not work. If i leave it without the pipeline triggers it does not work as well.

And after successfully testing the freestyle job and a standalone pipeline now the multi-branch one started to work.....Any hints why? (i did not change anything on Gitlab)

omehegan commented 7 years ago

@pgeorgiev333 The correct syntax for the properties line should be: properties([[$class: 'GitLabConnectionProperty', gitLabConnection: '<your-gitlab-connection-name']])

Where 'your-gitlab-connection-name' is the name you used when you set up the GitLab connection in the Jenkins global configuration.

pgeorgiev333 commented 7 years ago

I have a very good confidence that the workaround of setting up a Freestyle job first resolves the issue. I tried it on another gitlab server (this time community edition) using this flow:

  1. Create access token in gitlab
  2. Add gitlab entry in jenkins configuration (add the token and test the connection)
  3. Create the webhook (specify the jenkins url http://....project/testme and specify the same token )
  4. Create a freestyle job in jenkins (testme) using the configuration in the guide and make sure that it works (i.e. a commit triggers the job and the post-build step correctly update the gitlab commit status)
  5. Delete the freestyle job
  6. Create a multibranch pipeline job with the same name (testme) and configure as per the guide
  7. Test (it will work)

If you follow the steps but you create the multibranch job first it will hang. In this case just delete it, and execute steps 4 till 7.

Not sure if this has to be done for every webhook or for every new token but there is something fishy :)

omehegan commented 7 years ago

@pgeorgiev333 thanks a lot for this tip, I will look into this...

johnzeringue commented 7 years ago

I was having similar issues when I found this. Uninstalling the JaCoCo plugin seems to have resolved it for me.

pgeorgiev333 commented 7 years ago

Thanks. I added a note on the jacoco defect and I'll uninstall the plugin on my side to check (i do not use it at the moment anyway)

jglick commented 7 years ago

When calling JAXP methods, always set the Thread.contextClassLoader to a known value like ThisClass.class.getClassLoader() (then reset in a finally-block).