gpt4 book ai didi

git - 如何使用 jenkins shell 创建新的 git 分支

转载 作者:行者123 更新时间:2023-12-03 22:41:44 26 4
gpt4 key购买 nike

我想达到以下目的:

  1. In some jenkins job, create a new branch from dev-branch
  2. do some changes on the new created branch new-branch
  3. push the new created branch to git repo

我在 Jenkins 中执行了以下步骤:

  1. I have configured my git repo in the section "Source Code Management" and also the branches to build is my dev-branch.
  2. In Section Post Steps: Execute shell --> Command I have added the following:
git checkout -b new-branch
... do some changes
git add .
git commit -a -m "I have added some changes"
git push -u origin new-branch

现在当我运行这个作业时,我在控制台输出中得到以下内容:

+ git checkout -b R1.10.0.0_SII
Switched to a new branch 'new-branch'
+ git add .
+ git commit -a -m 'I have added some changes'
[new-branch 0dc7cf8] I have added some changes
+ git push -u origin new-branch
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Build step 'Execute shell' marked build as failure

如何使用 jenkins 创建一个新分支,做一些更改并正确推送新创建的分支?

最佳答案

首先需要执行git init命令初始化父仓库。然后尝试创建分支并添加。

关于git - 如何使用 jenkins shell 创建新的 git 分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37281341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com