git - 来自詹金斯管道的 Git 推送
问题描述
我想使用 jenkins 管道推送我的代码,那么有什么方法可以使用来自 jenkinsgit push
的HTTPS吗?
我们可以使用 GitHub 个人令牌进行 git push 吗?
解决方案
有许多不同的方法可以实现这一目标。我使用sh
步骤来运行 git 命令。
在本地暂存并提交更改后,推送命令将如下所示
def repoUrlWithAuth = "https://<username>:<token>@github.com/<username>/<repo>.git"
def sourceBranch = "<branch-to-push-to>"
git push --repo=${repoUrlWithAuth} --set-upstream ${repoUrlWithAuth} ${sourceBranch}
https://<username>:<token>@github.com/<username>/<repo>.git
如果初始克隆是使用--repo=${repoUrlWithAuth}
.
如果初始克隆具有正确的本地-远程分支映射,则不需要包含--set-upstream ${repoUrlWithAuth} ${sourceBranch}
这里还有另一个答案可能有助于解决这个问题。
推荐阅读
- mongodb - 如何使用 Mongo 更新在另一个集合中存在 _id 的所有文档?
- java - 无法访问变量,未找到初始化
- express - 是否可以在每个 cluster.task() 中传递不同的 puppeteerOptions?
- sql - Oracle Query:如何在插入记录时创建唯一键?
- excel - 为什么这个 IF 语句不能正常工作?即时窗口中的变量值表明它应该可以工作
- node.js - 如何使用 node --trace-warnings 运行 nx serve?
- arrays - 从 JWT 获取 __NSArray0
- python - 导入键盘段错误 python Macos Big Sur
- safari - 哪种视频编码格式支持可变比特率流式传输(质量)和用于跳过片段的 SEEK 功能?
- r - R:在ggplot中使用rollmean会在最后产生错误的下降