gitlab - Jenkins 无法将构建状态发布到 gitlab,管道显示待处理状态。这是一个多分支管道

标签 gitlab jenkins-pipeline devops multibranch-pipeline

我尝试了网上所有可能的解决方案。更改了我的 token 并具有所有权限。使用最新 token 更改了 gitlab 连接。 gitlab 中的仍然管道显示待处理状态。这些是来自 Jenkins 的日志。

Mar 23, 2022 5:37:19 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Mar 23, 2022 5:37:19 PM WARNING com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
No gitlab client found.
Mar 23, 2022 5:38:13 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Mar 23, 2022 5:38:13 PM WARNING com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
No gitlab client found.
Mar 23, 2022 5:38:13 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Mar 23, 2022 5:38:13 PM WARNING com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
No gitlab client found.
Mar 23, 2022 5:38:14 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Mar 23, 2022 5:38:14 PM WARNING com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
No gitlab client found.
Mar 23, 2022 5:38:14 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Mar 23, 2022 5:38:14 PM WARNING com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
No gitlab client found.
Mar 23, 2022 5:38:14 PM INFO com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
Retrieving gitlab project ids
Mar 23, 2022 5:38:14 PM WARNING com.dabsquared.gitlabjenkins.util.CommitStatusUpdater retrieveGitlabProjectIds
No gitlab client found.
Mar 23, 2022 5:38:15 PM INFO org.jenkinsci.plugins.workflow.job.WorkflowRun finish
multi/pipelines-check #79 completed: SUCCESS
Mar 23, 2022 5:38:15 PM INFO io.jenkins.plugins.generic.event.HttpEventSender send
Skipped event sending due to receiver URL not set
Mar 23, 2022 5:38:16 PM WARNING jenkins.util.Listeners lambda$notify$0
null
java.lang.NullPointerException
    at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabPipelineStatusNotifier.lambda$getStatusName$0(GitLabPipelineStatusNotifier.java:102)
    at java.logging/java.util.logging.Logger.log(Logger.java:1050)
    at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabPipelineStatusNotifier.getStatusName(GitLabPipelineStatusNotifier.java:101)
    at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabPipelineStatusNotifier.getStatusName(GitLabPipelineStatusNotifier.java:84)
    at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabPipelineStatusNotifier.logComment(GitLabPipelineStatusNotifier.java:178)
    at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabPipelineStatusNotifier.access$500(GitLabPipelineStatusNotifier.java:52)
    at io.jenkins.plugins.gitlabbranchsource.helpers.GitLabPipelineStatusNotifier$JobCompletedListener.onCompleted(GitLabPipelineStatusNotifier.java:484)
    at hudson.model.listeners.RunListener.lambda$fireCompleted$0(RunListener.java:207)
    at jenkins.util.Listeners.lambda$notify$0(Listeners.java:59)
    at jenkins.util.Listeners.notify(Listeners.java:67)
    at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:205)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:627)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$800(WorkflowRun.java:138)
    at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:1049)
    at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1474)
    at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:497)
    at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:38)
    at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139)
    at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
    at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

Jenkins 文件:

pipeline {
  agent {label 'xxx'}
  options {
     gitLabConnection('xxx')
          }

  stages {
     stage('Code') {
            steps {
            gitlabCommitStatus(connection:     gitLabConnection(gitLabConnection: 'xxx', jobCredentialId: 'xxx-xxx-xxx-xxx-xxxxx', useAlternativeCredential: true), name: 'Code_checkout') {
          checkout([$class: 'GitSCM', branches: [[name: '*/develop']], extensions: [[$class: 'GitLFSPull'], [$class: 'RelativeTargetDirectory', relativeTargetDir: 'xxxxxx']], userRemoteConfigs: [[url: '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="76111f0236111f021a17145815191b" rel="noreferrer noopener nofollow">[email protected]</a>:xxxxx/xxxxxx/root.git']]])
              sh'''
              cd xxxxxxxxx
              git submodule update --init --recursive
              cd /home/jenkins/jenkins_slave/workspace/ROOT/vds
              git checkout develop
              git pull
              cd xxxxxxxxxxx
              '''
              }
            }
     }
     stage('Testing') {
            steps {
                gitlabCommitStatus(connection:     gitLabConnection(gitLabConnection: 'xxxxxx', jobCredentialId: 'xxxxxxx', useAlternativeCredential: true), name: 'Testing') {
                echo "checking"
            }
        }
   }
  }

所有代码 checkout 部分和测试部分都在 shell 中进行

最佳答案

您可以在options block 中使用这两个参数

options {
    gitLabConnection('gitlab')
    gitlabBuilds(builds: ['build'])
}

在帖子部分,您可以像这样使用updateGitlabCommitStatus

post {
    failure {
      updateGitlabCommitStatus name: 'build', state: 'failed'
    }
    unstable {
      updateGitlabCommitStatus name: 'build', state: 'failed'
    }
    aborted {
      updateGitlabCommitStatus name: 'build', state: 'canceled'
    }
    success {
      updateGitlabCommitStatus name: 'build', state: 'success'
    }
    always {
    }
}

有关信息请查看此部分 https://github.com/jenkinsci/gitlab-plugin/blob/master/README.md

关于gitlab - Jenkins 无法将构建状态发布到 gitlab,管道显示待处理状态。这是一个多分支管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71591792/

相关文章:

phpstorm - 在gitlab上删除后如何删除phpstorm上的远程分支?

logging - 是否可以在 Jenkins 管道控制台输出中禁用 [Pipeline] 消息?

jenkins - 是否可以重命名默认的 "Declarative: Checkout SCM"步骤?

在 Ubuntu : "Unlink of file" 上使用 Samba 的 Git

node.js - Docker/GitLab : npm dependencies installed in docker image, 但通过运行器未满足

python - 使用gitlab cicd自动 merge 分支

jenkins - 如何在 Jenkins 多分支管道中安排具有特定参数的作业

ssh - 身份验证错误,隧道管理器中捕获未处理的异常 - 通过 SSH 使用 Mysql Workbench 连接到 digital ocean ubuntu 服务器

ant - 基于 Web 的复杂数据中心自动化工具

amazon-web-services - cloudformation - 是否可以拆分字符串并分配给列表中的属性?