我查看了 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
添加回答
舉報
0/150
提交
取消