Hudson/Jenkins Git build all branches

后端 未结 4 1876
面向向阳花
面向向阳花 2021-01-31 08:29

We have a lot of developers creating feature branches that I would like to build. Nightly we run a code quality tool that needs to run on every branch. I also would not like a s

4条回答
  •  囚心锁ツ
    2021-01-31 09:04

    I had the same problem to be solved. Specifically, make a zip file of all branches and offer those as artifacts to be used in different test jobs.

    In "Branches to build", put "**"

    Then, Execute shell:

    while read -ra ITEM; do
      for i in "${ITEM[@]}"; do
        git checkout $i
        
      done
    done <<< $(git branch -r | grep -v "HEAD ->" | xargs -L 1 | cut -d'/' -f2)
    

    This reads the list of branches, checkouts each of them separately and allows to do stuff in each of them. The <<< command converts this output:

      origin/HEAD -> origin/master
      origin/branch1
      origin/master
      origin/secondbranch
    

    into checkout usable list:

    branch1
    master
    secondbranch
    

提交回复
热议问题