git - 如何授予语义释放权限以将代码推送到 master
问题描述
我semantic-release
用来自动定义下一个版本,更新package.json
并推送到git
. 但是,我面临一个问题,它阻止我直接推送到master。
我正在使用GitLab。
我的release.config.js
module.exports = {
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
["@semantic-release/git", {
"assets": ["dist/**/*.{js,css}", "docs", "package.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}]
]
}
我的gitlab-ci.yml
package-versioning:
stage: package-versioning
tags:
- fe
- xdev
artifacts:
expire_in: 1 day
only:
refs:
- master
dependencies:
- install
- build
- test
script:
- npx semantic-release --tag-format 'app/v${version}'
错误:
The command "git push --dry-run --no-verify https://gitlab-ci-token:[secure]@***/**.git HEAD:master" failed with the error message remote: You are not allowed to upload code.
fatal: unable to access 'https://gitlab-ci-token:[secure]@***/**.git/': The requested URL returned error: 403.
[6:02:23 PM] [semantic-release] › ✖ EGITNOPERMISSION Cannot push to the Git repository.
semantic-release cannot push the version tag to the branch next on the remote Git repository with URL https://gitlab-ci-token:[secure]@***/**.git.
但我实际上是 repo 的所有者,并且已经将master的推送权限设置为唯一所有者。我是否需要为脚本配置任何其他身份验证才能代表我运行?
所以我的问题是:
1/ 如何为语义发布设置身份验证,以便它可以代表您直接推送到主控
2/直接推送到master是一个好习惯(即使它只用于版本更新)。有没有人遇到过这种情况以及更新版本的解决方案是什么。非常感谢您的意见和想法。
解决方案
1.在 GitLab 中,您必须明确设置要推送到 Git 的脚本。为此,您需要创建一个令牌并通过 env 变量将其传递给您的 CI。
例如,通过设置 GIT_PUSH_TOKEN 查看我们如何在集成项目中执行此操作 - 此处:https ://gitlab.com/taleodor/sample-helm-cd
以及此处的实际 ci yaml 代码:https ://gitlab.com/taleodor/sample-helm-cd/-/blob/master/.gitlab-ci.yml (第 25-30 行)。
2.是的,直接推送版本凹凸是常见的。
推荐阅读
- android - 任务':app:processDebugResources'第一次用户执行失败
- c++ - PCI Express 功能 ID 是必需的还是可选的?
- linux - 运行 apt-get 更新期间 Dockerfile 权限被拒绝
- python - 在 Python 3.8.10 中使用多处理而不使用 time.sleep() 时如何使进程休眠
- python - 带有 zip 功能的 for 循环只能工作一次
- ios - 有没有办法检测ios设备位置是否被没有越狱的软件模拟#flutter
- java - Android Firebase Realtime:将具有嵌套对象的对象写入数据库
- android - 可以将 ViewModel 传递给 RecyclerView(无 DataBinding)吗?
- angular - 星云主题和原始 HTML
- python - 如何使用 Selenium 找到要单击的确切文本?