2016-11-29 6 views
0

現在、DevopsというGitHubプロジェクト用のリポジトリを取得していて、マスターを取得しています。しかし今は、デフォルトで取得しているマスターの代わりにブランチを取得したいのですが、PowerShellスクリプトからそれを行う方法はわかりません。これがマスターブランチのために行われる方法です。powershellスクリプトタスクを使用してGitHubからmasterの代わりにbambooブランチを呼び出す方法

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

私はそれの終わりに-branchnameなど、.branchname、/ branchnameを追加しようとしましたが、それは私が代わりにマスターのブランチを見つけることができますどのように、枝を見つけられませんでしたか?

答えて

1

私はこのことで答えを得た:他の部分に

git clone -b BRANCH_NAME https://MYGIT:[email protected]/myRepo/devops 

をして、if文で私はこれでした:

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