jenkins gitlabCommitStatus已中断:无法更新项目HTTP 400错误请求的Gitlab提交状态

6tqwzwtp  于 2022-12-22  发布在  Jenkins
关注(0)|答案(3)|浏览(436)

我在Jenkins中间歇性地收到以下错误。到目前为止没有任何更改。Jenkins版本2.150.3和Gitlab插件版本1.5.11

20:31:01  Failed to update Gitlab commit status for project '10750': HTTP 400 Bad Request

jenkins服务器日志中的错误:

SEVERE: Failed to update Gitlab commit status for project '10750'
javax.ws.rs.BadRequestException: HTTP 400 Bad Request
        at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:197)
        at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.DefaultEntityExtractorFactory$3.extractEntity(DefaultEn
tityExtractorFactory.java:50)
        at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104)
        at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientProxy.invoke(ClientProxy.java:64)
        at com.dabsquared.gitlabjenkins.gitlab.api.impl.$Proxy152.changeBuildStatus(Unknown Source)
        at com.dabsquared.gitlabjenkins.gitlab.api.impl.ResteasyGitLabClient.changeBuildStatus(ResteasyGitLabClient.java:60)
        at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$7.execute(AutodetectingGitLabClient.java:1
12)
        at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$7.execute(AutodetectingGitLabClient.java:1
09)
        at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$GitLabOperation.execute(AutodetectingGitLa
bClient.java:335)
        at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient$GitLabOperation.access$100(AutodetectingGi
tLabClient.java:332)
        at com.dabsquared.gitlabjenkins.gitlab.api.impl.AutodetectingGitLabClient.execute(AutodetectingGitLabClient.java:328
)
ylamdve6

ylamdve61#

在调查这个问题后,我遇到了这个:
Commit status create (API): Can no longer use links under NAT with 'target_url'
在我们的组织中,由于Gitlab Community Edition已更新为11.11.8,因此发生错误

Status: 400 Bad Request
Response body: {
  "message" : {
    "target_url" : [ "is blocked: Host cannot be resolved or invalid" ]
  }
}

@devops您使用的是什么版本的Gitlab?您能提供Jenkins日志的响应体吗?

ttvkxqim

ttvkxqim2#

查看jenkinsci/gitlab-plugin问题522的评论是否有帮助:
只是为了其他可能会偶然发现这一点的人。
我的问题是,我试图在主项目SCM checkout 之前描述gitLabBuilds,然后在 checkout 之后更新它们。
这有一个奇怪的副作用,即为包含Jenkinsfile的repo(与主repo不同)创建GitLab管道作业,因此尝试更新错误repo的状态很可能导致了这个错误。
我花了一分钟重新启动gitlabBuilds和gitlabCommitStatus更新最后 checkout 的repo,如果顺序错误,它会尝试更新Jenkinsfile repo。
我相信这也会发生,如果你重新运行一个构建(无论是手动重发钩子,或重建)到一个合并请求已经合并/关闭。似乎你不能更新合并的PR的状态,这是有意义的。可能添加一些信息消息的情况下?
当我们在管道as explained here中使用共享库时,总是抛出BadRequestException: HTTP 400 Bad Request
显然,Jenkins克隆了两个存储库来构建任何项目:(1)共享库,以及(2)项目储存库。
随附jenkinsci/gitlab-plugin issue 885
我们也看到了这个错误。
在我们的案例中,这是由于Jenkins web hook在GitLab项目设置中为Merge Request事件注册了两次。

bn31dyow

bn31dyow3#

@VonC我也有类似的问题。Jenkins版本2.176.2和GitLab插件1.5.11
一天没有任何配置更改,但在GitLab更新到GitLab Community Edition 11.11.8之后
我正在接收Failed to update Gitlab commit status for project '2620': HTTP 400 Bad Request
我的Jenkins档案

pipeline {
  agent {
    docker {
      image 'trion/ng-cli-karma'
    }
  }
  options {
    gitLabConnection('https://xxxx.xxxx.xx/')
  }
  triggers {
    gitlab(
      branchFilterType: 'All',
      triggerOnPush: false,
      triggerOnMergeRequest: true,
      triggerOpenMergeRequestOnPush: "source",
      triggerOnAcceptedMergeRequest: true,
      triggerOnClosedMergeRequest: true,
      triggerOnNoteRequest: true,
      noteRegex: "Jenkins please retry a build",
      acceptMergeRequestOnSuccess: true,
      skipWorkInProgressMergeRequest: true,
      ciSkip: false,
      secretToken: "abcd",
      setBuildDescription: true,
      addNoteOnMergeRequest: true,
      addCiMessage: true,
      addVoteOnMergeRequest: true,
      includeBranchesSpec: "",
      excludeBranchesSpec: "",
      pendingBuildName: "",
      sourceBranchRegex: "",
      targetBranchRegex: "")
  }
  stages {
    stage('Check tools') {
      steps {
        gitlabCommitStatus('Check tools') {
          sh 'node -v'
          sh 'npm -v'
          sh 'npm i -g @angular/cli'
          sh 'npm rebuild node-sass --force'
        }
      }
    }
    stage('Checkout') {
      steps {
        checkout scm
      }
    }
    stage('Install modules') {
      steps {
        gitlabCommitStatus('`Install modules`') {
          sh 'npm install'
        }
      }
    }
    stage('Run lint') {
      steps {
        gitlabCommitStatus('lint') {
          sh 'npm run lint'
        }
      }
    }
    stage('Run tests') {
      steps {
        gitlabCommitStatus('test') {
          sh 'npm run test'
        }
      }
    }
    stage('Build') {
      steps {
        gitlabCommitStatus('build') {
          sh 'ng build --prod'
        }
      }
    }
  }
}

当我尝试用来自 Postman /CURL的get请求更新状态时,它工作得很好。

相关问题