Struggling with Git and multi stage yaml pipeline...

Copper Contributor

Hey,

Trying to do a multistage yaml pipeline and running into an issue with Git. My pipeline is starting off with creating a new branch based on the build id, snippet of the code below:

$exportBranchName = "PipelineRun_BuildId$(Build.BuildId)"
cd $(Build.SourcesDirectory)

git config user.email "email address removed for privacy reasons"
git config user.name "Pipeline"
                   
git checkout -b $exportBranchName
git push -u origin $exportBranchName

 

I'm then calling two separate template files that do slightly different things, however the ending in the templated files to push the changes into the above branch is the same in both. Strangely the second template file works, but the first fails with the error "fatal: not a git repository (or any of the parent directories): .git". Sample code below that's pushing the changes:

 

git fetch
$exportBranchName = "PipelineRun_BuildId$(Build.BuildId)"
cd $(Build.SourcesDirectory)
      
git config user.email "email address removed for privacy reasons"
git config global user.name "Pipeline"
      
git checkout $exportBranchName
git add --all
      
git commit -m "Comiting ${{ parameters.solutionName }} to branch PipelineRun_BuildId$(Build.BuildId)"
      
git -c http.extraheader="AUTHORIZATION: bearer $(System.AccessToken)" push --set-upstream origin $exportBranchName 

 

Just wondering if anyone has an idea to what's causing the first to fail, but not the second?

0 Replies