Argelbargel / gitlab-branch-source-plugin

Jenkins-Plugin to create a multi-branch-project from gitlab
GNU General Public License v2.0
71 stars 44 forks source link

Build status not being published #14

Closed ananace closed 7 years ago

ananace commented 7 years ago

As the title says, here's all the messages posted in the log during the build;

Mar 27, 2017 11:11:29 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO:  > git rev-parse --is-inside-work-tree # timeout=10
Mar 27, 2017 11:11:29 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO: Setting origin to https://gitlab.fqdn/group/project.git
Mar 27, 2017 11:11:29 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO:  > git config remote.origin.url https://gitlab.fqdn/group/project.git # timeout=10
Mar 27, 2017 11:11:29 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO: Fetching & pruning origin...
Mar 27, 2017 11:11:29 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO: Fetching upstream changes from origin
Mar 27, 2017 11:11:29 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO:  > git --version # timeout=10
Mar 27, 2017 11:11:29 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO:  > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/remotes/origin/tags/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/* --prune
Mar 27, 2017 11:11:30 AM jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
INFO: Done.
Mar 27, 2017 11:11:32 AM hudson.model.Run getEnvironment
WARNING: deprecated call to Run.getEnvironment
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Mar 27, 2017 11:12:06 AM org.jenkinsci.plugins.workflow.job.WorkflowRun finish
INFO: Gitlab/group%2Fproject/Merge Request Test (!20) merged #10 completed: SUCCESS
Mar 27, 2017 11:12:06 AM hudson.model.listeners.RunListener report
WARNING: RunListener failed
java.lang.NullPointerException
        at argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMPublishAction.updateRunningContexts(GitLabSCMPublishAction.java:105)
        at argelbargel.jenkins.plugins.gitlab_branch_source.actions.GitLabSCMPublishAction.publishResult(GitLabSCMPublishAction.java:96)
        at argelbargel.jenkins.plugins.gitlab_branch_source.GitLabSCMRunListener.onCompleted(GitLabSCMRunListener.java:38)
        at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:211)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:618)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$1400(WorkflowRun.java:125)
        at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:901)
        at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1110)
        at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:400)
        at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:35)
        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)

Mar 27, 2017 11:12:06 AM org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener publish
WARNING: Error publishing Run queued event.
org.jenkinsci.plugins.pubsub.MessageException: Event enrichment failure due to unexpected exception in io.jenkins.blueocean.events.BlueMessageEnricher.
        at org.jenkinsci.plugins.pubsub.PubsubBus.publish(PubsubBus.java:113)
        at org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener.publish(SyncQueueListener.java:178)
        at org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener.access$300(SyncQueueListener.java:57)
        at org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener$1.run(SyncQueueListener.java:106)
Caused by: org.acegisecurity.AccessDeniedException: Please log in to access Merge Request Test (!20) merged
        at com.cloudbees.hudson.plugins.folder.AbstractFolder.getItem(AbstractFolder.java:1167)
        at jenkins.branch.MultiBranchProject.getItem(MultiBranchProject.java:693)
        at io.jenkins.blueocean.rest.impl.pipeline.BranchContainerImpl.get(BranchContainerImpl.java:130)
        at io.jenkins.blueocean.rest.impl.pipeline.BranchContainerImpl.get(BranchContainerImpl.java:21)
        at io.jenkins.blueocean.rest.impl.pipeline.MultiBranchPipelineImpl$PipelineFactoryImpl.resolve(MultiBranchPipelineImpl.java:401)
        at io.jenkins.blueocean.service.embedded.rest.PipelineFolderImpl$PipelineFactoryImpl.resolve(PipelineFolderImpl.java:160)
        at io.jenkins.blueocean.service.embedded.rest.BluePipelineFactory.resolve(BluePipelineFactory.java:60)
        at io.jenkins.blueocean.service.embedded.LinkResolverImpl.resolveJob(LinkResolverImpl.java:50)
        at io.jenkins.blueocean.service.embedded.LinkResolverImpl.resolve(LinkResolverImpl.java:30)
        at io.jenkins.blueocean.rest.hal.LinkResolver.resolveLink(LinkResolver.java:32)
        at io.jenkins.blueocean.events.BlueMessageEnricher.enrich(BlueMessageEnricher.java:64)
        at org.jenkinsci.plugins.pubsub.PubsubBus.publish(PubsubBus.java:111)
        ... 3 more

And an excerpt from the project-specific job XML;

<!-- ... -->
        <source class="argelbargel.jenkins.plugins.gitlab_branch_source.GitLabSCMSource" plugin="gitlab-branch-source@0.5.1-dev">
          <id>group/project</id>
          <settings>
            <connectionName>gitlab.fqdn</connectionName>
            <credentialsId>ANONYMOUS</credentialsId>
            <includes>*</includes>
            <excludes></excludes>
            <branchMonitorStrategy>
              <monitor>true</monitor>
              <merged>false</merged>
              <unmerged>true</unmerged>
              <ignoreWIP>true</ignoreWIP>
              <onlyMergeable>false</onlyMergeable>
              <acceptMergeRequests>false</acceptMergeRequests>
              <removeSourceBranch>false</removeSourceBranch>
              <buildStatusPublishMode>stages</buildStatusPublishMode>
            </branchMonitorStrategy>
            <originMonitorStrategy>
              <!-- ... -->
              <buildStatusPublishMode>stages</buildStatusPublishMode>
            </originMonitorStrategy>
            <forksMonitorStrategy>
              <!-- ... -->
              <buildStatusPublishMode>stages</buildStatusPublishMode>
            </forksMonitorStrategy>
            <tagMonitorStrategy>
              <!-- ... -->
              <buildStatusPublishMode>stages</buildStatusPublishMode>
            </tagMonitorStrategy>
            <buildBranchesWithMergeRequests>false</buildBranchesWithMergeRequests>
            <registerWebHooks>false</registerWebHooks>
            <updateBuildDescription>true</updateBuildDescription>
            <publisherName>Jenkins</publisherName>
            <publishUnstableBuildsAsSuccess>true</publishUnstableBuildsAsSuccess>
            <mergeCommitMessage>Accepted Merge-Request #{0} after build {1} succeeded</mergeCommitMessage>
          </settings>
<!-- ... -->
Argelbargel commented 7 years ago

Hi again ;-)

i'll look into the NPE in GitLabSCMPublishAction. I'm not sure whether the other exception relates to gitlab-branch-source, though. Could also be a problem/bug in blueocean or the pubsub-light-plugin.

ananace commented 7 years ago

Considering the fact that it's talking about BlueOcean, I'm assuming that specific message relates to something in the BlueOcean UI. But I wanted to grab the entire log from the build just in case.

I'm curious though why there's not a single message from the build status publisher during the build though, seeing as it should be publishing build statuses for every stage.

An example layout for our templated pipeline;

stage('Source Preparation') {
        if (steps.preprepare) {
                steps.preprepare()
        }
        parallel(_wFallback(steps.prepare))
}

stage('Syntax Validation') {
        parallel(_wFallback(steps.validate))
}

stage('Testing') {
        parallel(_wFallback(steps.test))
}

stage('Packaging') {
        parallel(_wFallback(steps.package))
}

stage('Deployment') {
        parallel(_wFallback(steps.deploy))
}
Argelbargel commented 7 years ago

I'm not sure myself, but it seems that calling getActions(...).clear() does not always return the action i'm using to keep track of the stages and such. As this only happens at the end of the build, the statuses of the stages should be published.

ananace commented 7 years ago

Interesting, today I recreated the Gitlab folder to try out some other workflow libraries for internal things.

Still not getting any build statuses, but the error has disappeared.

Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
 > git rev-parse --is-inside-work-tree # timeout=10
Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
Setting origin to https://gitlab.fqdn/group/project.git
Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
 > git config remote.origin.url https://gitlab.fqdn/group/project.git # timeout=10
Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
Fetching & pruning origin...
Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
Fetching upstream changes from origin
Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
 > git --version # timeout=10
Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
 > git fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/remotes/origin/tags/* +refs/merge-requests/*/head:refs/remotes/origin/merge-requests/* --prune
Mar 28, 2017 2:55:41 PM INFO jenkins.plugins.git.GitSCMFileSystem$BuilderImpl build
Done.
Mar 28, 2017 2:55:55 PM INFO org.jenkinsci.plugins.workflow.job.WorkflowRun finish
Gitlab/group%2Fproject/test #6 completed: SUCCESS
Mar 28, 2017 2:55:56 PM WARNING org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener publish
Error publishing Run queued event.
org.acegisecurity.AccessDeniedException: Please log in to access test
    at com.cloudbees.hudson.plugins.folder.AbstractFolder.getItem(AbstractFolder.java:1167)
    at jenkins.branch.MultiBranchProject.getItem(MultiBranchProject.java:693)
    at io.jenkins.blueocean.rest.impl.pipeline.BranchContainerImpl.get(BranchContainerImpl.java:130)
    at io.jenkins.blueocean.rest.impl.pipeline.BranchContainerImpl.get(BranchContainerImpl.java:21)
    at io.jenkins.blueocean.rest.impl.pipeline.MultiBranchPipelineImpl$PipelineFactoryImpl.resolve(MultiBranchPipelineImpl.java:401)
    at io.jenkins.blueocean.service.embedded.rest.PipelineFolderImpl$PipelineFactoryImpl.resolve(PipelineFolderImpl.java:160)
    at io.jenkins.blueocean.service.embedded.rest.BluePipelineFactory.resolve(BluePipelineFactory.java:60)
    at io.jenkins.blueocean.service.embedded.LinkResolverImpl.resolveJob(LinkResolverImpl.java:50)
    at io.jenkins.blueocean.service.embedded.LinkResolverImpl.resolve(LinkResolverImpl.java:30)
    at io.jenkins.blueocean.rest.hal.LinkResolver.resolveLink(LinkResolver.java:32)
    at io.jenkins.blueocean.events.BlueMessageEnricher.enrich(BlueMessageEnricher.java:64)
    at org.jenkinsci.plugins.pubsub.PubsubBus.publish(PubsubBus.java:111)
Caused: org.jenkinsci.plugins.pubsub.MessageException: Event enrichment failure due to unexpected exception in io.jenkins.blueocean.events.BlueMessageEnricher.
    at org.jenkinsci.plugins.pubsub.PubsubBus.publish(PubsubBus.java:113)
    at org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener.publish(SyncQueueListener.java:178)
    at org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener.access$300(SyncQueueListener.java:57)
    at org.jenkinsci.plugins.pubsub.listeners.SyncQueueListener$1.run(SyncQueueListener.java:106)

If it helps, here's the XML dumps for the project hierarchy; ~jenkins/jobs/Gitlab/config.xml ~jenkins/jobs/Gitlab/jobs/project/config.xml ~jenkins/jobs/Gitlab/jobs/project/branches/test/config.xml

ananace commented 7 years ago

I managed to get build information to be published again through lots of cleanup - basically a full reinstall of Jenkins. It's still not reported properly though, so might've worked before just without me noticing it.

Here's an example screenshot of what's happening; screenshot_20170329_104704

The oldest of these is from the GitLab plugin itself, reporting the ref as only the branch name, which GitLab understands. This plugin on the other hand seems to report build statuses as the fully qualified ref name, which leaves GitLab with no idea where to link that build status.

Argelbargel commented 7 years ago

Ok. I think that's easy to fix.

ananace commented 7 years ago

I don't suppose there's been any progress on this fix?

Really want to start using this on the side, so I can begin phasing out the ~5k lines of Groovy code that emulates proper Jenkins pipelines in our system.

Argelbargel commented 7 years ago

Hi @ace13,

sorry, been a bit busy at work. No there is no progress on this bug yet. I'll try to fix this and release a new snapshot tomorrow night...

Argelbargel commented 7 years ago

Hi @ace13,

could you try out the new release? Publishing the build-status/linking to the right commit seems to be working (at least for my local install). Like to hear back and hope that you'll be able to use the plugin.

Kind regards,

Argelbargel

ananace commented 7 years ago

From the testing on my side it indeed looks like it does what it should now, thanks.