我们设置了 Jenkins 2 来构建对 github 的每次推送,并且我们不使用 Pull Request 构建器(尽管作为 pull request 的一部分的提交显然也会被构建)。GitHub 集成插件说它只适用于拉取请求构建器,所以这对我们不起作用。
我也尝试过github-notify plugin,但它似乎不适用于我们的案例(可能是因为 repo 是私有的和/或作为 Organizaiton 的一部分拥有,而不是个人用户)。我试过让它推断设置以及手动指定credentialsId
, account
, repo
, 当然还有status
参数,但都没有运气。
这是我的 Jenkinsfile 的缩写版本:
pipeline {
agent { label "centos7" }
stages {
stage("github => pending") {
steps {
githubNotify status: "PENDING", credentialsId: "my-credentials-id", account: "my-account", repo: "my-repo"
}
}
stage("build") {
...
}
}
post {
success {
githubNotify status: "SUCCESS", credentialsId: "my-credentials-id", account: "my-account", repo: "my-repo"
}
failure {
githubNotify status: "FAILURE", credentialsId: "my-credentials-id", account: "my-account", repo: "my-repo"
}
}
}
当我运行构建时,我得到以下信息:
java.lang.IllegalArgumentException: The suplied credentials are invalid to login
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep.getGitHubIfValid(GitHubStatusNotificationStep.java:234)
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep.getRepoIfValid(GitHubStatusNotificationStep.java:239)
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep.access$100(GitHubStatusNotificationStep.java:75)
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep$Execution.run(GitHubStatusNotificationStep.java:344)
at org.jenkinsci.plugins.pipeline.githubstatusnotification.GitHubStatusNotificationStep$Execution.run(GitHubStatusNotificationStep.java:326)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:221)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
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)
我已经通过 Jenkins(在配置系统区域)和在浏览器中手动测试了凭据——用户名和密码是正确的,并且具有对相关存储库的读/写访问权限。