为了账号安全,请及时绑定邮箱和手机立即绑定

Spring Cloud Config Server - 用于连接到 github 的用户

Spring Cloud Config Server - 用于连接到 github 的用户

饮歌长啸 2021-09-26 17:21:28
我查看了 github 存储库中许多 spring 云配置服务器的代码,下面是作为属性文件的一部分提供的 2 个值。我相信为了连接到 github 的 https 端点,用户 ID 和密码也是必要的。这些可能是环境变量的一部分吗?server.port=7070spring.cloud.config.server.git.uri=https://编辑:下面是我在 spring 网站上看到的示例。但是,在我企业内的所有 github 存储库中,我没有看到用户 ID 和密码被设置,因为它们是敏感信息。如果属性文件中未提供 uid / pwd ,如何设置或配置服务器访问 github url ?spring:  cloud:    config:      server:        git:          uri: https://github.com/spring-cloud-samples/config-repo          username: trolley          password: strongpassword
查看完整描述

4 回答

?
拉风的咖菲猫

TA贡献1995条经验 获得超2个赞

是的,只需使用这样的变量:



    spring.cloud.config.server.git.uri=${GIT_REPO_URL}

    spring.cloud.config.server.git.username=${GIT_USERNAME}

    spring.cloud.config.server.git.password=${GIT_TOKEN}


并在任何 CI 上设置这些环境变量。例如作为 GitHub Actions 上的秘密:



    - name: Build config-service

      env:

         GIT_REPO_URL: ${{ secrets.GIT_REPO_URL }}

         GIT_USERNAME: ${{ secrets.GIT_USERNAME }}

         GIT_TOKEN: ${{ secrets.GIT_TOKEN }}


似乎您不能再使用密码来访问 GitHub,您需要在此处顶部传递 GitHub 令牌 spring.cloud.config.server.git.password


查看完整回答
反对 回复 2021-09-26
  • 4 回答
  • 0 关注
  • 176 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信