-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding scaffolding script and readme
- Loading branch information
Showing
2 changed files
with
235 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
**Scaffolding.ps1** is a powershell script which helps users of an organization to have a standard getting started experience. | ||
|
||
## Sample command to invoke the script – | ||
|
||
.\scaffolding.ps1 -filePath .\org_details.txt | ||
|
||
## Input parameters expected | ||
|
||
You can either interactively provide inputs or pass a file instead. The contents of file would look something like this: | ||
|
||
org=https://dev.azure.com/contoso | ||
|
||
projectName=cliDemoScaffolding | ||
|
||
repoName=cli_repo | ||
|
||
repoToImport = https://github.com/ishitam8/snake.git | ||
|
||
teamName=Protocol CLI team | ||
|
||
[email protected],[email protected] | ||
|
||
[email protected],[email protected] | ||
|
||
[email protected],[email protected],[email protected] | ||
|
||
[email protected],[email protected] | ||
|
||
childIterationNamesList=Sprint 1,Sprint 2,Sprint 3 | ||
|
||
iterationsPermissionsBit=7 | ||
|
||
## What does this script do | ||
|
||
1. Your organization URL | ||
|
||
[org=https://dev.azure.com/contoso] | ||
|
||
2. Creates a new project under this organization | ||
|
||
[projectName=cliDemoScaffolding] | ||
|
||
3. Creates a new Repository | ||
|
||
[repoName=cli_repo] | ||
|
||
4. Repository URL to be imported in the newly created repo | ||
|
||
[repoToImport = https://github.com/ishitam8/snake.git] | ||
|
||
Accepts only public repo URL. | ||
|
||
5. List of required reviewers for configuring branch policies | ||
|
||
[requiredReviewers=[email protected],[email protected]] | ||
|
||
Currently, these branch policies are applied on master. | ||
|
||
6. List of required reviewers for configuring branch policies | ||
|
||
[optionalReviewers=[email protected],[email protected]] | ||
|
||
Currently, these branch policies are applied on master. | ||
|
||
7. Creates a team | ||
|
||
[teamName=Protocol CLI team] | ||
|
||
8. Adds the list of team members to the new team | ||
|
||
[teamMembers=[email protected],[email protected],[email protected]] | ||
|
||
9. Creates a corresponding admins group which would be used to manage this team. | ||
|
||
Add this admins group as `Team administrator` of this team. | ||
|
||
10. Adds the list of admin members to the team admin group | ||
|
||
[teamAdminMembers=[email protected],[email protected]] | ||
|
||
11. Boards settings for this team | ||
|
||
Setting up area | ||
|
||
- Creates a new area for this team and sets it to default area for this team. | ||
|
||
Iterations related settings | ||
|
||
- Creates a root iteration by the same name as team [i.e teamName]. | ||
- Creates child iterations which will be added this root iteration | ||
[childIterationNamesList=Sprint1,Sprint2,Sprint3]. | ||
- Configure/add these root and child iterations to the newly created team. | ||
- Give iterations related permissions to the admins group | ||
[iterationsPermissionsBit=7] | ||
The permission bit 7 denotes the addition of required permission bits to be allowed to this admins group. | ||
Which shall be as follows | ||
View permissions for this node = 1 | ||
Edit this node = 2 | ||
Create child nodes = 4 | ||
|
||
General settings | ||
|
||
- Configure backlog navigation settings [Currently assumed as epics: true, features: true, stories: true] | ||
- Configure working days [Currently assumed as Monday to Friday] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
|
||
param( | ||
[String]$filePath | ||
) | ||
. (Join-Path $PSScriptRoot .\Boards\boardsettings.ps1) | ||
. (Join-Path $PSScriptRoot .\Repos\setPolicies.ps1) | ||
. (Join-Path $PSScriptRoot .\configureTeam.ps1) | ||
|
||
|
||
#get input params | ||
|
||
if (!$filePath) { | ||
Write-Host("`nFile input not provided so switching the script to interactive mode to ask default parameters.") | ||
$org = "https://dev.azure.com/CliDemo" # Read-host("`nOrganization URL ") | ||
$projectName = Read-host("Project Name ") | ||
$repoName = Read-host("Repo Name ") | ||
$repoToImport = Read-host("Repo Import URL ") | ||
|
||
$requiredReviewersInput = Read-host("Required reviewers(Comma separated EMail IDs) ") | ||
$requiredReviewers = if ($requiredReviewersInput) { $requiredReviewersInput.split(",") } | ||
|
||
$optionalReviewersInput = Read-host("Optional reviewers(Comma separated EMail IDs) ") | ||
$optionalReviewers = if ($optionalReviewersInput) { $optionalReviewersInput.split(",") } | ||
|
||
$teamName = Read-host("Team Name ") | ||
|
||
$teamMembersInput = Read-host("Team Members(Comma separated EMail IDs) ") | ||
$teamMembers = if ($teamMembersInput) { $teamMembersInput.split(",") } | ||
|
||
$teamAdminMembersInput = Read-host("Team Admin Members(Comma separated EMail IDs) ") | ||
$teamAdminMembers = if ($teamAdminMembersInput) { $teamAdminMembersInput.split(",") } | ||
|
||
|
||
$childIterationNamesInput = Read-host("Child iterations list(Comma separated) ") | ||
$childIterationNamesList = if ($childIterationNamesInput) { $childIterationNamesInput.split(",") } | ||
|
||
Write-Host("`nThanks for providing all the required details. Now just sit back and relax, script is in action now . . . ") | ||
} | ||
else { | ||
$values = Get-Content $filePath | Out-String | ConvertFrom-StringData | ||
$org = $values.org | ||
$projectName = $values.projectName | ||
$repoName = $values.repoName | ||
$repoToImport = $values.repoToImport | ||
$teamName = $values.teamName | ||
$requiredReviewers = $values.requiredReviewers.split(",") | ||
$optionalReviewers = $values.optionalReviewers.split(",") | ||
$teamMembers = $values.teamMembers.split(",") | ||
$teamAdminMembers = $values.teamAdminMembers.split(",") | ||
$childIterationNamesList = $values.childIterationNamesList.split(",") | ||
$iterationsPermissionsBit = $values.iterationsPermissionsBit | ||
|
||
Write-Host("`nAll the required parameters are read from file at $($filePath) Now just sit back and relax, script is in action now . . . ") | ||
} | ||
|
||
$invokeRequestsPath = . Join-Path $PSScriptRoot InvokeRequests\ | ||
If (!(test-path $invokeRequestsPath)) { | ||
New-Item -ItemType Directory -Force -Path $invokeRequestsPath | ||
} | ||
|
||
# scaffolding | ||
Write-Host "`nCreating project with name $($projectName) . . . " | ||
$project = az devops project create --org $org --name $projectName --process Agile -o json | ConvertFrom-Json | ||
Write-Host "Created project with name $($project.name) and Id $($project.id)" | ||
|
||
|
||
if ($repoName) { | ||
Write-Host "`nCreating repository with name $($repoName) . . . " | ||
$repo = az repos create --org $org -p $projectName --name $repoName -o json | ConvertFrom-Json | ||
Write-Host "Created repository with name $($repo.name) and Id $($repo.id)" | ||
|
||
if ($repoToImport) { | ||
Write-Host "`nImporting repository from url $($repoToImport)" | ||
$importRepo = az repos import create --org $org -p $project.id -r $repo.id --git-url $repoToImport -o json | ConvertFrom-Json | ||
Write-Host "Repo imported with Status $($importRepo.status)" | ||
if ($requiredReviewers -or $optionalReviewers) { | ||
$policiesSet = set_policies -org $org -projectName $project.id -repoId $repo.id -branch 'master' -requiredApprovers $requiredReviewers -optionalApprovers $optionalReviewers | ||
Write-Host "`nBranch policies set for master" | ||
} | ||
} | ||
} | ||
else { | ||
Write-Host "`nSkipping repo creation as repo name is empty" | ||
} | ||
|
||
# team set up | ||
$apiVersion = '5.0' | ||
if ($teamName) { | ||
Write-Host "`nCreating team with name $($teamName) . . . " | ||
$createTeam = az devops team create --name $teamName --org $org -p $project.id -o json | ConvertFrom-Json | ||
Write-Host "Created team with name $($createTeam.name) and Id $($createTeam.id)" | ||
if ($teamMembers) { | ||
$listGroups = az devops security group list --org $org -p $project.id -o json | ConvertFrom-Json | ||
foreach ($grp in $listGroups.graphGroups) { | ||
if ($grp.displayName -eq $teamName) { | ||
# Add team members | ||
addTeamMembers -org $org -teamMembersList $teamMembers -teamDescriptor $grp.descriptor | ||
# create a team admin group and add it to this team | ||
$teamAdminGroupName = $teamName + ' Admins' | ||
$createTeamAdminsGroup = az devops security group create --org $org -p $project.id --name $teamAdminGroupName --groups $grp.descriptor -o json | ConvertFrom-Json | ||
Write-Host "`nCreated new admin group with name $($teamAdminGroupName) and added to the newly created team $($createTeam.name)." | ||
|
||
if ($teamAdminMembers) { | ||
addTeamMembers -org $org -teamMembersList $teamAdminMembers -teamDescriptor $createTeamAdminsGroup.descriptor | ||
} | ||
# add this newly created Admin group as Team Administrators | ||
addTeamAdmins -org $org -projectID $project.id -teamID $($createTeam.id) -adminGrpDescriptor $createTeamAdminsGroup.descriptor | ||
|
||
#create Area for this team | ||
createTeamArea -org $org -projectID $project.id -areaName $teamName | ||
|
||
# area path | ||
$areaPath = $projectName + '\' + $teamName | ||
configureDefaultArea -org $org -projectID $project.id -teamID $($createTeam.id) -defaultAreaPath $areaPath | ||
|
||
# Configure project level iterations with this group/team and grant permissions for admins group | ||
$projectIterationNameForThisTeam = $teamName + ' iteration' | ||
$rootIterationId = projectLevelIterationsSettings -org $org -projectID $project.id -rootIterationName $projectIterationNameForThisTeam -subject $createTeamAdminsGroup.descriptor -allow $iterationsPermissionsBit -childIterationNamesList $childIterationNamesList | ||
|
||
# Boards General settings | ||
setUpGeneralBoardSettings -org $org -projectID $project.id -teamID $($createTeam.id) -backlogIterationId $rootIterationId -epics $true -stories $true -features $true | ||
|
||
# Add child iterations of backlog iteration to the given team | ||
setUpTeamIterations -org $org -projectID $project.id -teamID $($createTeam.id) -backlogIterationName $projectIterationNameForThisTeam | ||
} | ||
} | ||
} | ||
} | ||
|
||
# clean up temp files for invoke requests | ||
Remove-Item -path .\InvokeRequests\ -recurse |