@cbs-consulting/generator-btp 1.2.10 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,158 @@
1
+ # Azure DevOps Setup Script
2
+
3
+ This directory contains a script to automate the configuration of your Azure DevOps repository with branch policies and CI/CD pipeline.
4
+
5
+ ## What This Script Does
6
+
7
+ The `setup.sh` script configures the following in your Azure DevOps repository:
8
+
9
+ ### Branch Configuration
10
+
11
+ - **Creates** the `development` branch if it doesn't exist
12
+ - **Optionally sets** `development` as the default branch (configurable)
13
+
14
+ ### `Main` Branch Policies
15
+
16
+ - **Minimum reviewers**: Requires at least 1 approver (configurable)
17
+ - **Prohibits self-approval**: The person who created the PR cannot approve it
18
+ - **Reset approvals on push**: Optionally reset votes when new commits are pushed (configurable)
19
+ - **Build validation**: Automatically runs the pipeline to validate PRs
20
+ - **Merge type restrictions** (all configurable):
21
+ - Squash merge (combines all commits into one)
22
+ - Rebase with merge commit (semi-linear history)
23
+ - Rebase and fast-forward (linear history, no merge commit)
24
+ - Basic merge/no fast-forward (preserves all commits and history)
25
+
26
+ ### Development Branch Policies
27
+
28
+ - **Build validation**: Automatically runs the pipeline to validate PRs
29
+ - **Merge type restrictions** (all configurable):
30
+ - Squash merge (combines all commits into one)
31
+ - Rebase with merge commit (semi-linear history)
32
+ - Rebase and fast-forward (linear history, no merge commit)
33
+ - Basic merge/no fast-forward (preserves all commits and history)
34
+
35
+ ### Pipeline
36
+
37
+ - **Creates** an Azure Pipeline named after your project (configurable)
38
+ - **Uses** a YAML file from your repository (default: `azure-pipelines.yml`, configurable)
39
+ - **Connects** to the `main` and `development` branch
40
+ - **Skips** the first automatic run
41
+
42
+ ## Prerequisites
43
+
44
+ Before running this script, ensure you have:
45
+
46
+ 1. **Azure CLI** installed
47
+
48
+ ```bash
49
+ # Check if installed
50
+ az --version
51
+
52
+ # Install if needed (Linux/macOS)
53
+ curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
54
+ ```
55
+
56
+ 2. **Azure DevOps extension** installed
57
+
58
+ ```bash
59
+ az extension add --name azure-devops
60
+ ```
61
+
62
+ 3. **Authenticated** to Azure
63
+
64
+ ```bash
65
+ az login --allow-no-subscriptions
66
+ ```
67
+
68
+ 4. **Appropriate permissions** in your Azure DevOps organization:
69
+ - Project Administrator or higher
70
+ - Or specific permissions for:
71
+ - Managing repository policies
72
+ - Creating pipelines
73
+ - Managing branches
74
+
75
+ ## Setup Instructions
76
+
77
+ ### Step 1: Configure Environment Variables
78
+
79
+ 1. Open the `azure-devops.env` file in this directory and review it.
80
+
81
+ ### Step 2: Run the Setup Script
82
+
83
+ Execute the script from this directory:
84
+
85
+ ```bash
86
+ bash setup.sh
87
+ ```
88
+
89
+ Or make it executable and run directly:
90
+
91
+ ```bash
92
+ chmod +x setup.sh
93
+ ./setup.sh
94
+ ```
95
+
96
+ ### Step 3: Verify Configuration
97
+
98
+ After the script completes successfully:
99
+
100
+ 1. Visit your Azure DevOps repository in your browser
101
+ 2. Navigate to **Repos** → **Branches**
102
+ 3. Verify:
103
+ - If configured, `development` is marked as the default branch
104
+ - Both `main` and `development` branches have policy icons
105
+ 4. Navigate to **Pipelines** to see your new pipeline
106
+
107
+ ## Configuration Options
108
+
109
+ All configuration is done through the `azure-devops.env` file:
110
+
111
+ ### Required Settings
112
+
113
+ | Variable | Description |
114
+ | ---------------------- | ---------------------------------- |
115
+ | `AZURE_DEVOPS_ORG_URL` | Your Azure DevOps organization URL |
116
+ | `AZURE_PROJECT_NAME` | Project name in Azure DevOps |
117
+
118
+ ### Branch Settings
119
+
120
+ | Variable | Description | Default |
121
+ | ----------------------------------- | ----------------------------------------- | ------------------------ |
122
+ | `REPO_NAME` | Repository name | Generated project's name |
123
+ | `MAIN_BRANCH` | Name of production branch | `main` |
124
+ | `DEV_BRANCH` | Name of development branch | `development` |
125
+ | `SET_DEVELOPMENT_BRANCH_AS_DEFAULT` | Set dev branch as default in Azure DevOps | `true` |
126
+
127
+ ### Main Branch Policy Settings
128
+
129
+ | Variable | Description | Default |
130
+ | ---------------------------- | ------------------------------------------------ | ------- |
131
+ | `MIN_REVIEWERS` | Minimum PR reviewers required | `1` |
132
+ | `MAIN_RESET_ON_SOURCE_PUSH` | Reset approvals when new commits are pushed | `true` |
133
+ | `MAIN_ALLOW_NO_FAST_FORWARD` | Allow basic merge (preserves all history) | `false` |
134
+ | `MAIN_ALLOW_SQUASH_MERGE` | Allow squash merge (all commits → 1 commit) | `true` |
135
+ | `MAIN_ALLOW_REBASE` | Allow rebase and fast-forward (linear, no merge) | `false` |
136
+ | `MAIN_ALLOW_REBASE_MERGE` | Allow rebase with merge commit (semi-linear) | `true` |
137
+
138
+ ### Development Branch Policy Settings
139
+
140
+ | Variable | Description | Default |
141
+ | --------------------------- | ------------------------------------------------ | ------- |
142
+ | `DEV_ALLOW_NO_FAST_FORWARD` | Allow basic merge (preserves all history) | `false` |
143
+ | `DEV_ALLOW_SQUASH_MERGE` | Allow squash merge (all commits → 1 commit) | `true` |
144
+ | `DEV_ALLOW_REBASE` | Allow rebase and fast-forward (linear, no merge) | `false` |
145
+ | `DEV_ALLOW_REBASE_MERGE` | Allow rebase with merge commit (semi-linear) | `true` |
146
+
147
+ ### Pipeline Settings
148
+
149
+ | Variable | Description | Default |
150
+ | -------------------- | ---------------------------------- | ------------------------ |
151
+ | `PIPELINE_NAME` | Name of the pipeline to create | Generated project's name |
152
+ | `PIPELINE_YAML_PATH` | Path to pipeline YAML file in repo | `azure-pipelines.yml` |
153
+
154
+ ## Additional Resources
155
+
156
+ - [Azure DevOps CLI documentation](https://docs.microsoft.com/en-us/cli/azure/devops)
157
+ - [Branch policies documentation](https://docs.microsoft.com/en-us/azure/devops/repos/git/branch-policies)
158
+ - [Azure Pipelines documentation](https://docs.microsoft.com/en-us/azure/devops/pipelines/)
@@ -0,0 +1,113 @@
1
+ ###############################################################################
2
+ # Azure DevOps Configuration
3
+ #
4
+ # This file contains configuration for the Azure DevOps setup script.
5
+ # Please update the values below to match your Azure DevOps organization and
6
+ # project settings.
7
+ ###############################################################################
8
+
9
+ # -----------------------------------------------------------------------------
10
+ # Azure DevOps Organization and Project
11
+ # -----------------------------------------------------------------------------
12
+
13
+ # Your Azure DevOps organization URL
14
+ # Example: https://dev.azure.com/myorganization
15
+ AZURE_DEVOPS_ORG_URL="<%= azureDevOpsOrgUrl %>"
16
+
17
+ # The name of your Azure DevOps project
18
+ # This is the project that contains your repository
19
+ # You find it in the URL of your Azure DevOps project: https://dev.azure.com/YOUR_ORGANIZATION/YOUR_PROJECT_NAME/_git/REPO_NAME
20
+ AZURE_PROJECT_NAME="<%= azureProjectName %>"
21
+
22
+ # -----------------------------------------------------------------------------
23
+ # Repository Configuration
24
+ # -----------------------------------------------------------------------------
25
+
26
+ # The name of the repository in Azure DevOps
27
+ # Default: Project name from generator
28
+ # You find it in the URL of your Azure DevOps repository: https://dev.azure.com/YOUR_ORGANIZATION/YOUR_PROJECT_NAME/_git/REPO_NAME
29
+ REPO_NAME="<%= repoName %>"
30
+
31
+ # -----------------------------------------------------------------------------
32
+ # Branch Configuration
33
+ # -----------------------------------------------------------------------------
34
+
35
+ # Name of the main/production branch
36
+ MAIN_BRANCH="<%= mainBranch %>"
37
+
38
+ # Name of the development branch
39
+ DEV_BRANCH="<%= devBranch %>"
40
+
41
+ # Whether to set the development branch as the default branch in Azure DevOps
42
+ # true = development branch becomes default (recommended for active development)
43
+ # false = main branch stays as default
44
+ SET_DEVELOPMENT_BRANCH_AS_DEFAULT=<%= setDevBranchAsDefault %>
45
+
46
+ # -----------------------------------------------------------------------------
47
+ # Main Branch Policy Settings
48
+ # -----------------------------------------------------------------------------
49
+
50
+ # Minimum number of reviewers required for pull requests to main
51
+ MIN_REVIEWERS=<%= minReviewers %>
52
+
53
+ # Whether approvals are reset when new commits are pushed to a PR targeting main
54
+ # true = reviewers must re-approve after each code push (more secure)
55
+ # false = approvals persist even after new commits (faster workflow)
56
+ MAIN_RESET_ON_SOURCE_PUSH=<%= mainResetOnSourcePush %>
57
+
58
+ # Merge strategy options for main branch:
59
+
60
+ # Allow basic merge (no fast-forward) - Standard merge that preserves all commits
61
+ # Preserves complete branch history with merge commits
62
+ MAIN_ALLOW_NO_FAST_FORWARD=<%= mainAllowNoFastForward %>
63
+
64
+ # Allow squash merge - Combines all PR commits into a single commit (recommended)
65
+ # Creates clean, linear history
66
+ MAIN_ALLOW_SQUASH_MERGE=<%= mainAllowSquashMerge %>
67
+
68
+ # Allow rebase and fast-forward - Replays commits on target without merge commit
69
+ # Creates completely linear history
70
+ MAIN_ALLOW_REBASE=<%= mainAllowRebase %>
71
+
72
+ # Allow rebase with merge commit - Replays commits on target then creates merge commit
73
+ # Creates semi-linear history
74
+ MAIN_ALLOW_REBASE_MERGE=<%= mainAllowRebaseMerge %>
75
+
76
+ # Note: The script automatically:
77
+ # - Sets creator-vote-counts to false (prohibits self-approval)
78
+ # - Requires minimum reviewers before merge
79
+ # - Enables build validation for PRs
80
+
81
+ # -----------------------------------------------------------------------------
82
+ # Development Branch Policy Settings
83
+ # -----------------------------------------------------------------------------
84
+
85
+ # Merge strategy options for development branch:
86
+
87
+ # Allow basic merge (no fast-forward) - Standard merge that preserves all commits
88
+ # Preserves complete branch history with merge commits
89
+ DEV_ALLOW_NO_FAST_FORWARD=<%= devAllowNoFastForward %>
90
+
91
+ # Allow squash merge - Combines all PR commits into a single commit (recommended)
92
+ # Creates clean, linear history
93
+ DEV_ALLOW_SQUASH_MERGE=<%= devAllowSquashMerge %>
94
+
95
+ # Allow rebase and fast-forward - Replays commits on target without merge commit
96
+ # Creates completely linear history
97
+ DEV_ALLOW_REBASE=<%= devAllowRebase %>
98
+
99
+ # Allow rebase with merge commit - Replays commits on target then creates merge commit
100
+ # Creates semi-linear history
101
+ DEV_ALLOW_REBASE_MERGE=<%= devAllowRebaseMerge %>
102
+
103
+ # -----------------------------------------------------------------------------
104
+ # Pipeline Configuration
105
+ # -----------------------------------------------------------------------------
106
+
107
+ # Name of the Azure Pipeline to create
108
+ # Default: Project name from generator
109
+ PIPELINE_NAME="<%= pipelineName %>"
110
+
111
+ # Path to the pipeline YAML file in the repository
112
+ # This file defines the build/test/deploy steps for your CI/CD pipeline
113
+ PIPELINE_YAML_PATH="<%= pipelineYamlPath %>"