Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit ba71649

Browse files
mtarngbnookala
authored andcommitted
Adding support for pipeline installs in other branches
1 parent 5547e2e commit ba71649

File tree

12 files changed

+63
-27
lines changed

12 files changed

+63
-27
lines changed

guides/hld-management.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,15 @@ Usage: hld install-manifest-pipeline|p [options]
102102
Install the manifest generation pipeline to your Azure DevOps instance. Default values are set in spk-config.yaml and can be loaded via spk init or overriden via option flags.
103103
104104
Options:
105-
-n, --pipeline-name <pipeline-name> Name of the pipeline to be created
106-
-p, --personal-access-token <personal-access-token> Personal Access Token
107-
-o, --org-name <org-name> Organization Name for Azure DevOps
108-
-r, --hld-name <hld-name> HLD Repository Name in Azure DevOps
109-
-u, --hld-url <hld-url> HLD Repository URL
110-
-m, --manifest-url <manifest-url> Manifest Repository URL
111-
-d, --devops-project <devops-project> Azure DevOps Project
112-
-b, --build-script-url <build-script-url> Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'.
105+
-n, --pipeline-name <pipeline-name> Name of the pipeline to be created (default: "")
106+
-p, --personal-access-token <personal-access-token> Personal Access Token (default: "")
107+
-o, --org-name <org-name> Organization Name for Azure DevOps (default: "")
108+
-r, --hld-name <hld-name> HLD Repository Name in Azure DevOps (default: "")
109+
-u, --hld-url <hld-url> HLD Repository URL (default: "")
110+
-m, --manifest-url <manifest-url> Manifest Repository URL (default: "")
111+
-d, --devops-project <devops-project> Azure DevOps Project (default: "")
112+
-b, --build-script-url <build-script-url> Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'. (default: "https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh")
113+
--yaml-file-branch <yaml-file-branch> The git branch where the pipeline definition yaml file is located. (default: "master")
113114
-h, --help output usage information
114115
```
115116

guides/project-management.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Options:
117117
-r, --repo-name <repo-name> Repository Name in Azure DevOps
118118
-u, --repo-url <repo-url> Repository URL
119119
-d, --devops-project <devops-project> Azure DevOps Project
120-
-b, --build-script-url <build-script-url> Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'.
120+
-b, --build-script-url <build-script-url> Build Script URL. By default it is https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh.
121+
--yaml-file-branch <yaml-file-branch> The git branch where the pipeline definition yaml file is located. (default: "master")
121122
-h, --help output usage information
122123
```

guides/service-management.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,15 @@ Usage: service install-build-pipeline|p [options] <service-name>
9898
Install the build and push to acr pipeline for a service to your Azure DevOps instance
9999
100100
Options:
101-
-n, --pipeline-name <pipeline-name> Name of the pipeline to be created
102-
-p, --personal-access-token <personal-access-token> Personal Access Token
103-
-o, --org-name <org-name> Organization Name for Azure DevOps
104-
-r, --repo-name <repo-name> Repository Name in Azure DevOps
105-
-u, --repo-url <repo-url> Repository URL
106-
-d, --devops-project <devops-project> Azure DevOps Project
107-
-b, --build-script-url <build-script-url> Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'.
101+
-n, --pipeline-name <pipeline-name> Name of the pipeline to be created (default: "")
102+
-p, --personal-access-token <personal-access-token> Personal Access Token (default: "")
103+
-o, --org-name <org-name> Organization Name for Azure DevOps (default: "")
104+
-r, --repo-name <repo-name> Repository Name in Azure DevOps (default: "")
105+
-u, --repo-url <repo-url> Repository URL (default: "")
106+
-d, --devops-project <devops-project> Azure DevOps Project (default: "")
107+
-b, --build-script-url <build-script-url> Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'. (default: "https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh")
108108
-l, --packages-dir <packages-dir> The mono-repository directory containing this service definition. ie. '--packages-dir packages' if my-service is located under ./packages/my-service. Omitting this option implies this is a not a mono-repository.
109+
--yaml-file-branch <yaml-file-branch> The git branch where the pipeline definition yaml file is located. (default: "master")
109110
-h, --help output usage information
110111
```
111112

src/commands/hld/pipeline.decorator.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
"arg": "-b, --build-script-url <build-script-url>",
4343
"description": "Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'.",
4444
"defaultValue": "https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh"
45+
},
46+
{
47+
"arg": "--yaml-file-branch <yaml-file-branch>",
48+
"description": "The git branch where the pipeline definition yaml file is located.",
49+
"required": false,
50+
"defaultValue": "master"
4551
}
4652
]
4753
}

src/commands/hld/pipeline.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ const MOCKED_VALUES: ICommandOptions = {
3030
manifestUrl: "https://dev.azure.com/test/fabrikam/_git/materialized",
3131
orgName: "orgName",
3232
personalAccessToken: "personalAccessToken",
33-
pipelineName: "pipelineName"
33+
pipelineName: "pipelineName",
34+
yamlFileBranch: "master"
3435
};
3536

3637
const MOCKED_CONFIG = {
@@ -92,7 +93,8 @@ describe("test populateValues function", () => {
9293
manifestUrl: "",
9394
orgName: "",
9495
personalAccessToken: "",
95-
pipelineName: ""
96+
pipelineName: "",
97+
yamlFileBranch: ""
9698
});
9799

98100
expect(values.buildScriptUrl).toBe(BUILD_SCRIPT_URL);
@@ -113,6 +115,7 @@ describe("test populateValues function", () => {
113115
"-to-" +
114116
getRepositoryName(MOCKED_CONFIG.azure_devops.manifest_repository)
115117
);
118+
expect(values.yamlFileBranch).toBe("");
116119
});
117120
});
118121

src/commands/hld/pipeline.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface ICommandOptions {
3030
manifestUrl: string;
3131
devopsProject: string;
3232
buildScriptUrl: string;
33+
yamlFileBranch: string;
3334
}
3435

3536
export const emptyStringIfUndefined = (val: string | undefined) => {
@@ -132,7 +133,7 @@ export const installHldToManifestPipeline = async (values: ICommandOptions) => {
132133
values.buildScriptUrl,
133134
values.manifestUrl
134135
),
135-
yamlFileBranch: "master",
136+
yamlFileBranch: values.yamlFileBranch,
136137
yamlFilePath: RENDER_HLD_PIPELINE_FILENAME
137138
} as IAzureRepoPipelineConfig);
138139

src/commands/project/pipeline.decorator.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
"arg": "-b, --build-script-url <build-script-url>",
3838
"description": "Build Script URL. By default it is https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh.",
3939
"required": true
40+
},
41+
{
42+
"arg": "--yaml-file-branch <yaml-file-branch>",
43+
"description": "The git branch where the pipeline definition yaml file is located.",
44+
"required": false,
45+
"defaultValue": "master"
4046
}
4147
]
4248
}

src/commands/project/pipeline.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const mockValues: ICommandOptions = {
3232
personalAccessToken: "PAT",
3333
pipelineName: "pipelineName",
3434
repoName: "repoName",
35-
repoUrl: "repoUrl"
35+
repoUrl: "repoUrl",
36+
yamlFileBranch: "master"
3637
};
3738

3839
const mockMissingValues: ICommandOptions = {
@@ -42,7 +43,8 @@ const mockMissingValues: ICommandOptions = {
4243
personalAccessToken: undefined,
4344
pipelineName: undefined,
4445
repoName: undefined,
45-
repoUrl: undefined
46+
repoUrl: undefined,
47+
yamlFileBranch: ""
4648
};
4749

4850
const gitUrl = "https://github.com/CatalystCode/spk.git";

src/commands/project/pipeline.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface ICommandOptions {
4040
repoName: string | undefined;
4141
repoUrl: string | undefined;
4242
buildScriptUrl: string | undefined;
43+
yamlFileBranch: string;
4344
}
4445

4546
export const checkDependencies = (projectPath: string) => {
@@ -78,7 +79,8 @@ export const fetchValidateValues = (
7879
pipelineName:
7980
opts.pipelineName || getRepositoryName(gitOriginUrl) + "-lifecycle",
8081
repoName: opts.repoName || getRepositoryName(gitOriginUrl),
81-
repoUrl: opts.repoUrl || getRepositoryUrl(gitOriginUrl)
82+
repoUrl: opts.repoUrl || getRepositoryUrl(gitOriginUrl),
83+
yamlFileBranch: opts.yamlFileBranch
8284
};
8385

8486
const map: { [key: string]: string | undefined } = {};
@@ -146,7 +148,8 @@ export const commandDecorator = (command: commander.Command) => {
146148

147149
const createPipeline = async (
148150
values: ICommandOptions,
149-
devopsClient: IBuildApi
151+
devopsClient: IBuildApi,
152+
definitionBranch: string
150153
): Promise<BuildDefinition> => {
151154
const definition = definitionForAzureRepoPipeline({
152155
branchFilters: ["master"], // hld reconcile pipeline is triggered only by merges into the master branch.
@@ -155,7 +158,7 @@ const createPipeline = async (
155158
repositoryName: values.repoName!,
156159
repositoryUrl: values.repoUrl!,
157160
variables: requiredPipelineVariables(values.buildScriptUrl!),
158-
yamlFileBranch: "master", // Pipeline is defined in master
161+
yamlFileBranch: definitionBranch, // Pipeline is defined in master
159162
yamlFilePath: PROJECT_PIPELINE_FILENAME // Pipeline definition lives in root directory.
160163
});
161164

@@ -186,7 +189,11 @@ export const installLifecyclePipeline = async (values: ICommandOptions) => {
186189
);
187190
logger.info("Fetched DevOps Client");
188191

189-
const pipeline = await createPipeline(values, devopsClient);
192+
const pipeline = await createPipeline(
193+
values,
194+
devopsClient,
195+
values.yamlFileBranch
196+
);
190197
if (typeof pipeline.id === "undefined") {
191198
const builtDefnString = JSON.stringify(pipeline);
192199
throw Error(

src/commands/service/pipeline.decorator.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
{
4242
"arg": "-l, --packages-dir <packages-dir>",
4343
"description": "The mono-repository directory containing this service definition. ie. '--packages-dir packages' if my-service is located under ./packages/my-service. Omitting this option implies this is a not a mono-repository."
44+
},
45+
{
46+
"arg": "--yaml-file-branch <yaml-file-branch>",
47+
"description": "The git branch where the pipeline definition yaml file is located.",
48+
"required": false,
49+
"defaultValue": "master"
4450
}
4551
]
4652
}

0 commit comments

Comments
 (0)