在詹金斯(Jenkins)工作区下将特征分支与母版合并

时间:2019-12-14 12:15:35

标签: jenkins jenkins-pipeline

我用詹金斯创建了一个名为NetLab的管道项目。 我有多个分支,并且在扫描远程GitHub存储库后,我发现Jenkins为它们创建了不同的目录:

vagrant@vagrant:~$ ll /var/lib/jenkins/workspace/
total 36
drwxr-xr-x  8 jenkins jenkins 4096 Dec 11 18:44  ./
drwxr-xr-x 21 jenkins jenkins 4096 Dec 14 11:56  ../
drwxr-xr-x  8 jenkins jenkins 4096 Dec 11 19:14  NetLab_jenkinsbranch/
drwxr-xr-x  2 jenkins jenkins 4096 Dec 14 10:59 'NetLab_jenkinsbranch@tmp'/
drwxr-xr-x  8 jenkins jenkins 4096 Dec 11 18:50  NetLab_master/
drwxr-xr-x  2 jenkins jenkins 4096 Dec 11 18:30 'NetLab_master@tmp'/
-rw-r--r--  1 jenkins jenkins   70 Dec 11 18:43  workspaces.txt

我有多个阶段,我想执行以下操作:

  1. 检测非主分支中的更改
  2. 在非主分支下进行一些操作
  3. 如果第2步成功,则将非master分支与master合并
  4. 在主分支下执行步骤2中的相同操作
  5. 如果成功,请执行更多操作,并将本地Jenkins主服务器推送到GitHub

由于在Jenkins工作空间下存在用于主分支和非主分支的单独文件夹,所以我陷入了Step3的困境,我不能只切换到master分支并将我的分支合并到master。我该怎么办?

vagrant@vagrant:~$ ll /var/lib/jenkins/workspace/
total 36
drwxr-xr-x  8 jenkins jenkins 4096 Dec 11 18:44  ./
drwxr-xr-x 21 jenkins jenkins 4096 Dec 14 11:56  ../
drwxr-xr-x  8 jenkins jenkins 4096 Dec 11 19:14  NetLab_jenkinsbranch/
drwxr-xr-x  2 jenkins jenkins 4096 Dec 14 10:59 'NetLab_jenkinsbranch@tmp'/
drwxr-xr-x  8 jenkins jenkins 4096 Dec 11 18:50  NetLab_master/
drwxr-xr-x  2 jenkins jenkins 4096 Dec 11 18:30 'NetLab_master@tmp'/
-rw-r--r--  1 jenkins jenkins   70 Dec 11 18:43  workspaces.txt

vagrant@vagrant:/var/lib/jenkins/workspace$ git status
fatal: not a git repository (or any of the parent directories): .git


vagrant@vagrant:/var/lib/jenkins/workspace$ cd NetLab_jenkinsbranch
vagrant@vagrant:/var/lib/jenkins/workspace/NetLab_jenkinsbranch$ git status
HEAD detached at 82b6b0b
vagrant@vagrant:/var/lib/jenkins/workspace/NetLab_jenkinsbranch$ git branch
* (HEAD detached at 82b6b0b)

vagrant@vagrant:/var/lib/jenkins/workspace/NetLab_jenkinsbranch$ cd ../NetLab_master
NetLab_master/     NetLab_master@tmp/
vagrant@vagrant:/var/lib/jenkins/workspace/NetLab_jenkinsbranch$ cd ../NetLab_master
vagrant@vagrant:/var/lib/jenkins/workspace/NetLab_master$ git status
HEAD detached at afb5310
nothing to commit, working tree clean

vagrant@vagrant:/var/lib/jenkins/workspace/NetLab_master$ git merge NetLab_jenkinsbranch
merge: NetLab_jenkinsbranch - not something we can merge

0 个答案:

没有答案