如果 CI 作业中的任何检查失败,我们如何禁用 github 中拉取请求的合并

Ram*_*ran 5 github github-actions

我们有一个 Jenkins CI 作业,当提出拉取请求时,我们将在其中运行作业。如果该作业在任何情况下失败,我们就不应该允许用户合并拉取请求。我们有什么办法可以使用 github actions 来做吗?

Von*_*onC 5

你可以:

\n\n

OP Ramanichandran在评论中确认其正在发挥作用:

\n
\n

对于 jenkins 中的每个失败阶段,我们称之为 github api

\n
\n
sh(\'curl "https://api.github.com/repos/reponame/statuses/$GIT_COMMIT?access_token=xxx" \\ \n-H "Content-Type: application/json" \\ \n-X POST \\ \n-d "{\\\\\\"state\\\\\\": \\\\\\"failure\\\\\\", \\\\\\"target_url\\\\\\": \\\\\\"https://jenkinsurl/job/foldername/job/jobname/$BUILD_NUMBER/console\\\\\\", \\\\\\"description\\\\\\": \\\\\\"Jenkins-CI-pre-merge-job-sonarscan-failure\\\\\\", \\\\\\"context\\\\\\": \\\\\\"Jenkins-CI-pre-merge-job-sonarscan-failure\\\\\\"}"\') } \xe2\x80\x93\n
Run Code Online (Sandbox Code Playgroud)\n