如何使用jenkins shell创建新的git分支 [英] How to create new git branch with jenkins shell

查看:415
本文介绍了如何使用jenkins shell创建新的git分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想达成以下目标:

  1. 在某些詹金斯工作中,从dev-branch创建一个新分支
  2. 在新创建的分支new-branch上进行一些更改
  3. 将新创建的分支推送到git repo
  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)中执行了以下步骤:

I did the following steps in Jenkins:

  1. 我已在源代码管理"部分中配置了git repo,并且要构建的分支是我的dev-branch.
  2. 在发布步骤:执行shell->命令"小节中,我添加了以下内容:

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

现在,当我运行此作业时,会在控制台输出中得到以下信息:

Now when I run this job I get the following in the console output:

+ 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创建新分支,进行一些更改并正确推送新创建的分支?

How to create a new branch with jenkins, do some changes and push the new created branch correctly?

推荐答案

首先,您需要执行git init命令初始化为父存储库.然后尝试创建分支并添加.

First you need to perform git init command to initialize to parent repository. Then try creating branch and add.

这篇关于如何使用jenkins shell创建新的git分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆