Save/SaveAppsInRepository.ps1
function SaveAppsInRepository { param ( [Parameter(Mandatory=$true)] [string]$prName, [Parameter(Mandatory=$true)] [string]$branchName, [Parameter(Mandatory=$true)] [string]$filterName, [Parameter(Mandatory=$true)] [string]$pathToPreviousapps, [Parameter(Mandatory=$true)] [string]$pathToArtifacts, [Parameter(Mandatory=$true)] $SystemCollectionUri, [Parameter(Mandatory=$true)] $SystemTeamProject, [Parameter(Mandatory=$true)] $SystemAccessToken, [Parameter(Mandatory=$true)] $BuildRepositoryName ) try { az devops configure --defaults organization="$SystemCollectionUri" project="$SystemTeamProject" --use-git-aliases true } catch { Write-Error "An error occurred while configuring Azure DevOps: $_" } try { git fetch origin master git checkout master git checkout -b $branchName Get-ChildItem -Path "$pathToPreviousapps" -Filter $filterName | Remove-Item Copy-Item -Path $pathToArtifacts -Destination "$pathToPreviousapps" -Recurse git add "$pathToPreviousapps" git commit -m $prName git push origin $branchName } catch { Write-Error "An error occurred while working with Git: $_" } try { $env:AZURE_DEVOPS_EXT_PAT = "$SystemAccessToken" az devops login --organization "$SystemCollectionUri" az repos pr create --repository "$BuildRepositoryName" --source-branch $branchName --target-branch master --title $prName --description $prName } catch { Write-Error "An error occurred while creating the pull request: $_" } } |