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

Commit 17a1e2f

Browse files
authored
Fixing the noop broken project lifecycle pipeline (#202)
* Fixing build script url option * docs * Adding Build scripts back to project install pipelines * docs * Actually hooking in isValidConfig for service pipeline * adding -url
1 parent 60c3cca commit 17a1e2f

File tree

8 files changed

+44
-80
lines changed

8 files changed

+44
-80
lines changed

docs/hld-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Options:
8989
-u, --hld-url <hld-url> HLD Repository URL
9090
-m, --manifest-url <manifest-url> Manifest Repository URL
9191
-d, --devops-project <devops-project> Azure DevOps Project
92-
-b, --build-script <build-script-url> Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'.
92+
-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'.
9393
-h, --help output usage information
9494
```
9595

docs/project-management.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ Options:
116116
-o, --org-name <org-name> Organization Name for Azure DevOps
117117
-r, --repo-name <repo-name> Repository Name in Azure DevOps
118118
-u, --repo-url <repo-url> Repository URL
119-
-e, --hld-url <hld-url> HLD Repository URL
120119
-d, --devops-project <devops-project> Azure DevOps Project
121-
-b, --build-script <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'.
122121
-h, --help output usage information
123122
```

docs/service-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Options:
7777
-r, --repo-name <repo-name> Repository Name in Azure DevOps
7878
-u, --repo-url <repo-url> Repository URL
7979
-d, --devops-project <devops-project> Azure DevOps Project
80-
-b, --build-script <build-script-url> Build Script URL. By default it is 'https://raw.githubusercontent.com/Microsoft/bedrock/master/gitops/azure-devops/build.sh'.
80+
-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'.
8181
-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.
8282
-h, --help output usage information
8383
```

src/commands/hld/pipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const installHldToManifestPipelineDecorator = (
3939
.option("-m, --manifest-url <manifest-url>", "Manifest Repository URL")
4040
.option("-d, --devops-project <devops-project>", "Azure DevOps Project")
4141
.option(
42-
"-b, --build-script <build-script-url>",
42+
"-b, --build-script-url <build-script-url>",
4343
`Build Script URL. By default it is '${BUILD_SCRIPT_URL}'.`
4444
)
4545
.action(async opts => {

src/commands/project/pipeline.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ describe("validate pipeline config", () => {
2424
"testDevopsProject",
2525
"testPipeline",
2626
"repoName",
27-
"https:/repoulr",
28-
"https://hldurl",
27+
"https://repourl",
2928
"https://buildscript",
3029
"af8e99c1234ef93e8c4365b1dc9bd8d9ba987d3"
3130
];
@@ -57,7 +56,6 @@ describe("create hld to manifest pipeline test", () => {
5756
"pipelineName",
5857
"repoName",
5958
"repoUrl",
60-
"hldRepoUrl",
6159
"azDoProject",
6260
"buildScriptUrl",
6361
exitFn
@@ -76,7 +74,6 @@ describe("create hld to manifest pipeline test", () => {
7674
"pipelineName",
7775
"repoName",
7876
"repoUrl",
79-
"hldRepoUrl",
8077
"azDoProject",
8178
"buildScriptUrl",
8279
exitFn
@@ -98,7 +95,6 @@ describe("create hld to manifest pipeline test", () => {
9895
"pipelineName",
9996
"repoName",
10097
"repoUrl",
101-
"hldRepoUrl",
10298
"azDoProject",
10399
"buildScriptUrl",
104100
exitFn
@@ -119,7 +115,6 @@ describe("create hld to manifest pipeline test", () => {
119115
"pipelineName",
120116
"repoName",
121117
"repoUrl",
122-
"hldRepoUrl",
123118
"azDoProject",
124119
"buildScriptUrl",
125120
exitFn
@@ -145,7 +140,6 @@ describe("create hld to manifest pipeline test", () => {
145140
"pipelineName",
146141
"repoName",
147142
"repoUrl",
148-
"hldRepoUrl",
149143
"azDoProject",
150144
"buildScriptUrl",
151145
exitFn

src/commands/project/pipeline.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { IBuildApi } from "azure-devops-node-api/BuildApi";
2-
import { BuildDefinition } from "azure-devops-node-api/interfaces/BuildInterfaces";
2+
import {
3+
BuildDefinition,
4+
BuildDefinitionVariable
5+
} from "azure-devops-node-api/interfaces/BuildInterfaces";
36
import commander from "commander";
47
import { Config } from "../../config";
58
import { BUILD_SCRIPT_URL } from "../../lib/constants";
@@ -37,10 +40,9 @@ export const deployLifecyclePipelineCommandDecorator = (
3740
.option("-o, --org-name <org-name>", "Organization Name for Azure DevOps")
3841
.option("-r, --repo-name <repo-name>", "Repository Name in Azure DevOps")
3942
.option("-u, --repo-url <repo-url>", "Repository URL")
40-
.option("-e, --hld-url <hld-url>", "HLD Repository URL")
4143
.option("-d, --devops-project <devops-project>", "Azure DevOps Project")
4244
.option(
43-
"-b, --build-script <build-script-url>",
45+
"-b, --build-script-url <build-script-url>",
4446
`Build Script URL. By default it is '${BUILD_SCRIPT_URL}'.`
4547
)
4648
.action(async opts => {
@@ -64,7 +66,6 @@ export const deployLifecyclePipelineCommandDecorator = (
6466
pipelineName = getRepositoryName(gitOriginUrl) + "-lifecycle",
6567
repoName = getRepositoryName(gitOriginUrl),
6668
repoUrl = getRepositoryUrl(gitOriginUrl),
67-
hldUrl = azure_devops && azure_devops.hld_repository,
6869
buildScriptUrl = BUILD_SCRIPT_URL
6970
} = opts;
7071

@@ -73,9 +74,8 @@ export const deployLifecyclePipelineCommandDecorator = (
7374
orgName,
7475
devopsProject,
7576
pipelineName,
77+
repoName,
7678
repoUrl,
77-
hldUrl,
78-
hldUrl,
7979
buildScriptUrl,
8080
personalAccessToken
8181
)
@@ -90,7 +90,6 @@ export const deployLifecyclePipelineCommandDecorator = (
9090
pipelineName,
9191
repoName,
9292
repoUrl,
93-
hldUrl,
9493
devopsProject,
9594
buildScriptUrl,
9695
process.exit
@@ -113,7 +112,6 @@ export const deployLifecyclePipelineCommandDecorator = (
113112
* @param pipelineName Name of this build pipeline in AzDo
114113
* @param repoName Name of repo
115114
* @param repoUrl Repo URL
116-
* @param hldUrl URL of the HLD
117115
* @param buildScriptUrl Build Script URL
118116
* @param personalAccessToken Personal Access token with access to the HLD repository and materialized manifest repository.
119117
*/
@@ -123,7 +121,6 @@ export const isValidConfig = (
123121
pipelineName: any,
124122
repoName: any,
125123
repoUrl: any,
126-
hldUrl: any,
127124
buildScriptUrl: any,
128125
personalAccessToken: any
129126
): boolean => {
@@ -134,7 +131,6 @@ export const isValidConfig = (
134131
logger.debug(`pipelineName: ${pipelineName}`);
135132
logger.debug(`repoName: ${repoName}`);
136133
logger.debug(`repoUrl: ${repoUrl}`);
137-
logger.debug(`hldUrl: ${hldUrl}`);
138134
logger.debug(`devopsProject: ${devopsProject}`);
139135
logger.debug(`buildScriptUrl: ${buildScriptUrl}`);
140136

@@ -163,19 +159,14 @@ export const isValidConfig = (
163159
`--repo-url must be of type 'string', ${typeof repoUrl} given.`
164160
);
165161
}
166-
if (typeof hldUrl !== "string") {
167-
missingConfig.push(
168-
`--hld-url must be of type 'string', ${typeof hldUrl} given.`
169-
);
170-
}
171162
if (typeof devopsProject !== "string") {
172163
missingConfig.push(
173164
`--devops-project must be of type 'string', ${typeof devopsProject} given.`
174165
);
175166
}
176167
if (typeof buildScriptUrl !== "string") {
177168
missingConfig.push(
178-
`--build-script must be of type 'string', ${typeof buildScriptUrl} given.`
169+
`--build-script-url must be of type 'string', ${typeof buildScriptUrl} given.`
179170
);
180171
}
181172

@@ -195,7 +186,6 @@ export const isValidConfig = (
195186
* @param pipelineName
196187
* @param repositoryName
197188
* @param repositoryUrl
198-
* @param hldRepoUrl
199189
* @param project
200190
* @param buildScriptUrl Build Script URL
201191
* @param exitFn
@@ -206,7 +196,6 @@ export const installLifecyclePipeline = async (
206196
pipelineName: string,
207197
repositoryName: string,
208198
repositoryUrl: string,
209-
hldRepoUrl: string,
210199
project: string,
211200
buildScriptUrl: string,
212201
exitFn: (status: number) => void
@@ -229,6 +218,7 @@ export const installLifecyclePipeline = async (
229218
pipelineName,
230219
repositoryName,
231220
repositoryUrl,
221+
variables: requiredPipelineVariables(buildScriptUrl),
232222
yamlFileBranch: "master",
233223
yamlFilePath: "hld-lifecycle.yaml"
234224
});
@@ -267,3 +257,21 @@ export const installLifecyclePipeline = async (
267257
return exitFn(1);
268258
}
269259
};
260+
261+
/**
262+
* Builds and returns variables required for the lifecycle pipeline.
263+
* @param buildScriptUrl Build Script URL
264+
* @returns Object containing the necessary run-time variables for the lifecycle pipeline.
265+
*/
266+
267+
export const requiredPipelineVariables = (
268+
buildScriptUrl: string
269+
): { [key: string]: BuildDefinitionVariable } => {
270+
return {
271+
BUILD_SCRIPT_URL: {
272+
allowOverride: true,
273+
isSecret: false,
274+
value: buildScriptUrl
275+
}
276+
};
277+
};

src/commands/service/pipeline.ts

Lines changed: 12 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const installBuildPipelineCommandDecorator = (
4242
.option("-u, --repo-url <repo-url>", "Repository URL")
4343
.option("-d, --devops-project <devops-project>", "Azure DevOps Project")
4444
.option(
45-
"-b, --build-script <build-script-url>",
45+
"-b, --build-script-url <build-script-url>",
4646
`Build Script URL. By default it is '${BUILD_SCRIPT_URL}'.`
4747
)
4848
.option(
@@ -64,54 +64,17 @@ export const installBuildPipelineCommandDecorator = (
6464
buildScriptUrl = BUILD_SCRIPT_URL
6565
} = opts;
6666

67-
logger.debug(`orgName: ${orgName}`);
68-
logger.debug(`personalAccessToken: XXXXXXXXXXXXXXXXX`);
69-
logger.debug(`devopsProject: ${devopsProject}`);
70-
logger.debug(`pipelineName: ${pipelineName}`);
71-
logger.debug(`packagesDir: ${packagesDir}`);
72-
logger.debug(`repoName: ${repoName}`);
73-
logger.debug(`repoUrl: ${repoUrl}`);
74-
logger.debug(`buildScriptUrl: ${buildScriptUrl}`);
75-
76-
try {
77-
if (typeof pipelineName !== "string") {
78-
throw new Error(
79-
`--pipeline-name must be of type 'string', ${typeof pipelineName} given.`
80-
);
81-
}
82-
if (typeof personalAccessToken !== "string") {
83-
throw new Error(
84-
`--personal-access-token must be of type 'string', ${typeof personalAccessToken} given.`
85-
);
86-
}
87-
if (typeof orgName !== "string") {
88-
throw new Error(
89-
`--org-url must be of type 'string', ${typeof orgName} given.`
90-
);
91-
}
92-
if (typeof repoName !== "string") {
93-
throw new Error(
94-
`--repo-name must be of type 'string', ${typeof repoName} given.`
95-
);
96-
}
97-
if (typeof repoUrl !== "string") {
98-
throw new Error(
99-
`--repo-url must be of type 'string', ${typeof repoUrl} given.`
100-
);
101-
}
102-
if (typeof devopsProject !== "string") {
103-
throw new Error(
104-
`--devops-project must be of type 'string', ${typeof devopsProject} given.`
105-
);
106-
}
107-
if (typeof buildScriptUrl !== "string") {
108-
throw new Error(
109-
`--build-script must be of type 'string', ${typeof buildScriptUrl} given.`
110-
);
111-
}
112-
} catch (err) {
113-
logger.error(`Error occurred validating inputs for ${serviceName}`);
114-
logger.error(err);
67+
if (
68+
!isValidConfig(
69+
orgName,
70+
devopsProject,
71+
pipelineName,
72+
repoName,
73+
repoUrl,
74+
buildScriptUrl,
75+
personalAccessToken
76+
)
77+
) {
11578
process.exit(1);
11679
}
11780

tests/validations.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ lifecycle_pipeline_name="$mono_repo_dir-lifecycle"
191191
pipeline_exists $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name
192192

193193
# Deploy lifecycle pipeline and verify it runs.
194-
spk project install-lifecycle-pipeline --org-name $AZDO_ORG --devops-project $AZDO_PROJECT --hld-url $hld_repo_url --repo-url $repo_url --repo-name $mono_repo_dir --pipeline-name $lifecycle_pipeline_name --personal-access-token $ACCESS_TOKEN_SECRET >> $TEST_WORKSPACE/log.txt
194+
spk project install-lifecycle-pipeline --org-name $AZDO_ORG --devops-project $AZDO_PROJECT --repo-url $repo_url --repo-name $mono_repo_dir --pipeline-name $lifecycle_pipeline_name --personal-access-token $ACCESS_TOKEN_SECRET >> $TEST_WORKSPACE/log.txt
195195

196196
# TODO: Verify the lifecycle pipeline sucessfully runs
197197
# Verify lifecycle pipeline was created

0 commit comments

Comments
 (0)