jenkins - 如何在 Github 组织插件中使用两个因素
问题描述
我们正在对 GitHub 组织中的所有用户强制执行两因素身份验证。
当我们启用它时,我们所有的 Jenkins 工作都很好,除了我们的“Github 组织”工作。
似乎这个插件只支持用户名/密码凭据,而不是 id_rsa 或 access_tokens,它们可以很好地与两因素身份验证配合使用。
如果您使用用户名/access_token 凭据,则会拒绝访问:
java.io.FileNotFoundException:
[https://api.github.com/]
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:243)
at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
at org.kohsuke.github.Requester.parse(Requester.java:612)
at org.kohsuke.github.Requester.parse(Requester.java:594)
at org.kohsuke.github.Requester._to(Requester.java:272)
Caused: org.kohsuke.github.GHFileNotFoundException: \{"message":"Must specify two-factor authentication OTP code.","documentation_url":"
[https://developer.github.com/v3/auth#working-with-two-factor-authentication]
"}
at org.kohsuke.github.Requester.handleApiError(Requester.java:686)
at org.kohsuke.github.Requester._to(Requester.java:293)
at org.kohsuke.github.Requester.to(Requester.java:234)
at org.kohsuke.github.GitHub.checkApiUrlValidity(GitHub.java:703)
at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.checkApiUrlValidity(GitHubSCMSource.java:1348)
at org.jenkinsci.plugins.github_branch_source.GitHubSCMSource.retrieve(GitHubSCMSource.java:1401)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:564)
at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:95)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:295)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE
我在这里输入了一张票(我不确定这是一个错误还是有解决方法,因此我在这里交叉发布) https://issues.jenkins-ci.org/browse/JENKINS-51092
甚至帮助文本都说它只支持用户名/密码组合(附图片)。
这个项目的 config.xml 文件的顶部是这样的:
看起来这已经在其他地方修复了,但不是这个插件: https ://issues.jenkins-ci.org/browse/JENKINS-39477
解决方案
推荐阅读
- android - 在没有后端服务器的情况下,在颤振和原生(android 和 ios)之间创建数据库连接的最佳方法是什么?
- firebase - 带有填充和 TextAlign 的 Flutter Dart 错误
- java - 如何修复 HDFS org.apache.hadoop.hdfs.DistributedFileSystem 未找到
- scala - sbt shell 中的任何命令都会引发 `expected ';'` 错误
- debian - Debian WSL 错误:您必须在 sources.list 中放入一些“源”URI
- ios - 谁最终负责为磁盘上的 URL 设置 URLResourceValues?
- xml - Jackson XmlMapper 序列化嵌套对象@JacksonXmlProperty(isAttribute = true) 无法正常工作
- sql-server - 使用 GORM 在 GO 语言中处理来自 sql 的多个结果集
- rust - 如何获取结构的 LLVMTypeRef?
- ruby-on-rails - 检查注册参数后,如何在 Rails API 控制器中创建 JSON 响应以在 React Native 中使用?