如何使用PowerShell脚本任务来调用Github的Bamboo Branch代替Master



我当前正在获取一个名为DevOps的GitHub项目的存储库,并且正在获得主人。但是现在,我想获得分支,而不是默认情况下它得到的主人,但我不知道如何从PowerShell脚本进行。这就是主分支的完成方式。

cd ${bamboo.build.working.directory}
if [ -d devops ] ; then
cd devops 2>/dev/null && git pull || git clone https://MYGIT:myGIT@github.com/myRepo/devops
else
git clone https://MYGIT:myGIT@github.com/myRepo/devops
fi

我尝试将.branchname,/branchName,-branchname等添加到它的末端,但是它找不到分支,我该如何找到分支而不是主人?

我通过这样做得到了答案:

git clone -b BRANCH_NAME https://MYGIT:myGIT@github.com/myRepo/devops

对于其他部分,然后在if语句中我做到了:

# Get the current branch
function gitBranchName {
    $currentBranch = "master"
    git branch | foreach {
        if ($_ -match "<branch_name>") {
            $currentBranch = "<branch_name>"
        }
    }
    return $currentBranch
}

最新更新