Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/hld-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Options:
-u, --hld-url <hld-url> HLD Repository URL
-m, --manifest-url <manifest-url> Manifest Repository URL
-d, --devops-project <devops-project> Azure DevOps Project
-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'.
-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'.
-h, --help output usage information
```

Expand Down
3 changes: 1 addition & 2 deletions docs/project-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ Options:
-o, --org-name <org-name> Organization Name for Azure DevOps
-r, --repo-name <repo-name> Repository Name in Azure DevOps
-u, --repo-url <repo-url> Repository URL
-e, --hld-url <hld-url> HLD Repository URL
-d, --devops-project <devops-project> Azure DevOps Project
-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'.
-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'.
-h, --help output usage information
```
2 changes: 1 addition & 1 deletion docs/service-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Options:
-r, --repo-name <repo-name> Repository Name in Azure DevOps
-u, --repo-url <repo-url> Repository URL
-d, --devops-project <devops-project> Azure DevOps Project
-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'.
-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'.
-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.
-h, --help output usage information
```
Expand Down
2 changes: 1 addition & 1 deletion src/commands/hld/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const installHldToManifestPipelineDecorator = (
.option("-m, --manifest-url <manifest-url>", "Manifest Repository URL")
.option("-d, --devops-project <devops-project>", "Azure DevOps Project")
.option(
"-b, --build-script <build-script-url>",
"-b, --build-script-url <build-script-url>",
`Build Script URL. By default it is '${BUILD_SCRIPT_URL}'.`
)
.action(async opts => {
Expand Down
8 changes: 1 addition & 7 deletions src/commands/project/pipeline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ describe("validate pipeline config", () => {
"testDevopsProject",
"testPipeline",
"repoName",
"https:/repoulr",
"https://hldurl",
"https://repourl",
"https://buildscript",
"af8e99c1234ef93e8c4365b1dc9bd8d9ba987d3"
];
Expand Down Expand Up @@ -57,7 +56,6 @@ describe("create hld to manifest pipeline test", () => {
"pipelineName",
"repoName",
"repoUrl",
"hldRepoUrl",
"azDoProject",
"buildScriptUrl",
exitFn
Expand All @@ -76,7 +74,6 @@ describe("create hld to manifest pipeline test", () => {
"pipelineName",
"repoName",
"repoUrl",
"hldRepoUrl",
"azDoProject",
"buildScriptUrl",
exitFn
Expand All @@ -98,7 +95,6 @@ describe("create hld to manifest pipeline test", () => {
"pipelineName",
"repoName",
"repoUrl",
"hldRepoUrl",
"azDoProject",
"buildScriptUrl",
exitFn
Expand All @@ -119,7 +115,6 @@ describe("create hld to manifest pipeline test", () => {
"pipelineName",
"repoName",
"repoUrl",
"hldRepoUrl",
"azDoProject",
"buildScriptUrl",
exitFn
Expand All @@ -145,7 +140,6 @@ describe("create hld to manifest pipeline test", () => {
"pipelineName",
"repoName",
"repoUrl",
"hldRepoUrl",
"azDoProject",
"buildScriptUrl",
exitFn
Expand Down
44 changes: 26 additions & 18 deletions src/commands/project/pipeline.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { IBuildApi } from "azure-devops-node-api/BuildApi";
import { BuildDefinition } from "azure-devops-node-api/interfaces/BuildInterfaces";
import {
BuildDefinition,
BuildDefinitionVariable
} from "azure-devops-node-api/interfaces/BuildInterfaces";
import commander from "commander";
import { Config } from "../../config";
import { BUILD_SCRIPT_URL } from "../../lib/constants";
Expand Down Expand Up @@ -37,10 +40,9 @@ export const deployLifecyclePipelineCommandDecorator = (
.option("-o, --org-name <org-name>", "Organization Name for Azure DevOps")
.option("-r, --repo-name <repo-name>", "Repository Name in Azure DevOps")
.option("-u, --repo-url <repo-url>", "Repository URL")
.option("-e, --hld-url <hld-url>", "HLD Repository URL")
.option("-d, --devops-project <devops-project>", "Azure DevOps Project")
.option(
"-b, --build-script <build-script-url>",
"-b, --build-script-url <build-script-url>",
`Build Script URL. By default it is '${BUILD_SCRIPT_URL}'.`
)
.action(async opts => {
Expand All @@ -64,7 +66,6 @@ export const deployLifecyclePipelineCommandDecorator = (
pipelineName = getRepositoryName(gitOriginUrl) + "-lifecycle",
repoName = getRepositoryName(gitOriginUrl),
repoUrl = getRepositoryUrl(gitOriginUrl),
hldUrl = azure_devops && azure_devops.hld_repository,
buildScriptUrl = BUILD_SCRIPT_URL
} = opts;

Expand All @@ -73,9 +74,8 @@ export const deployLifecyclePipelineCommandDecorator = (
orgName,
devopsProject,
pipelineName,
repoName,
repoUrl,
hldUrl,
hldUrl,
buildScriptUrl,
personalAccessToken
)
Expand All @@ -90,7 +90,6 @@ export const deployLifecyclePipelineCommandDecorator = (
pipelineName,
repoName,
repoUrl,
hldUrl,
devopsProject,
buildScriptUrl,
process.exit
Expand All @@ -113,7 +112,6 @@ export const deployLifecyclePipelineCommandDecorator = (
* @param pipelineName Name of this build pipeline in AzDo
* @param repoName Name of repo
* @param repoUrl Repo URL
* @param hldUrl URL of the HLD
* @param buildScriptUrl Build Script URL
* @param personalAccessToken Personal Access token with access to the HLD repository and materialized manifest repository.
*/
Expand All @@ -123,7 +121,6 @@ export const isValidConfig = (
pipelineName: any,
repoName: any,
repoUrl: any,
hldUrl: any,
buildScriptUrl: any,
personalAccessToken: any
): boolean => {
Expand All @@ -134,7 +131,6 @@ export const isValidConfig = (
logger.debug(`pipelineName: ${pipelineName}`);
logger.debug(`repoName: ${repoName}`);
logger.debug(`repoUrl: ${repoUrl}`);
logger.debug(`hldUrl: ${hldUrl}`);
logger.debug(`devopsProject: ${devopsProject}`);
logger.debug(`buildScriptUrl: ${buildScriptUrl}`);

Expand Down Expand Up @@ -163,19 +159,14 @@ export const isValidConfig = (
`--repo-url must be of type 'string', ${typeof repoUrl} given.`
);
}
if (typeof hldUrl !== "string") {
missingConfig.push(
`--hld-url must be of type 'string', ${typeof hldUrl} given.`
);
}
if (typeof devopsProject !== "string") {
missingConfig.push(
`--devops-project must be of type 'string', ${typeof devopsProject} given.`
);
}
if (typeof buildScriptUrl !== "string") {
missingConfig.push(
`--build-script must be of type 'string', ${typeof buildScriptUrl} given.`
`--build-script-url must be of type 'string', ${typeof buildScriptUrl} given.`
);
}

Expand All @@ -195,7 +186,6 @@ export const isValidConfig = (
* @param pipelineName
* @param repositoryName
* @param repositoryUrl
* @param hldRepoUrl
* @param project
* @param buildScriptUrl Build Script URL
* @param exitFn
Expand All @@ -206,7 +196,6 @@ export const installLifecyclePipeline = async (
pipelineName: string,
repositoryName: string,
repositoryUrl: string,
hldRepoUrl: string,
project: string,
buildScriptUrl: string,
exitFn: (status: number) => void
Expand All @@ -229,6 +218,7 @@ export const installLifecyclePipeline = async (
pipelineName,
repositoryName,
repositoryUrl,
variables: requiredPipelineVariables(buildScriptUrl),
yamlFileBranch: "master",
yamlFilePath: "hld-lifecycle.yaml"
});
Expand Down Expand Up @@ -267,3 +257,21 @@ export const installLifecyclePipeline = async (
return exitFn(1);
}
};

/**
* Builds and returns variables required for the lifecycle pipeline.
* @param buildScriptUrl Build Script URL
* @returns Object containing the necessary run-time variables for the lifecycle pipeline.
*/

export const requiredPipelineVariables = (
buildScriptUrl: string
): { [key: string]: BuildDefinitionVariable } => {
return {
BUILD_SCRIPT_URL: {
allowOverride: true,
isSecret: false,
value: buildScriptUrl
}
};
};
61 changes: 12 additions & 49 deletions src/commands/service/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const installBuildPipelineCommandDecorator = (
.option("-u, --repo-url <repo-url>", "Repository URL")
.option("-d, --devops-project <devops-project>", "Azure DevOps Project")
.option(
"-b, --build-script <build-script-url>",
"-b, --build-script-url <build-script-url>",
`Build Script URL. By default it is '${BUILD_SCRIPT_URL}'.`
)
.option(
Expand All @@ -64,54 +64,17 @@ export const installBuildPipelineCommandDecorator = (
buildScriptUrl = BUILD_SCRIPT_URL
} = opts;

logger.debug(`orgName: ${orgName}`);
logger.debug(`personalAccessToken: XXXXXXXXXXXXXXXXX`);
logger.debug(`devopsProject: ${devopsProject}`);
logger.debug(`pipelineName: ${pipelineName}`);
logger.debug(`packagesDir: ${packagesDir}`);
logger.debug(`repoName: ${repoName}`);
logger.debug(`repoUrl: ${repoUrl}`);
logger.debug(`buildScriptUrl: ${buildScriptUrl}`);

try {
if (typeof pipelineName !== "string") {
throw new Error(
`--pipeline-name must be of type 'string', ${typeof pipelineName} given.`
);
}
if (typeof personalAccessToken !== "string") {
throw new Error(
`--personal-access-token must be of type 'string', ${typeof personalAccessToken} given.`
);
}
if (typeof orgName !== "string") {
throw new Error(
`--org-url must be of type 'string', ${typeof orgName} given.`
);
}
if (typeof repoName !== "string") {
throw new Error(
`--repo-name must be of type 'string', ${typeof repoName} given.`
);
}
if (typeof repoUrl !== "string") {
throw new Error(
`--repo-url must be of type 'string', ${typeof repoUrl} given.`
);
}
if (typeof devopsProject !== "string") {
throw new Error(
`--devops-project must be of type 'string', ${typeof devopsProject} given.`
);
}
if (typeof buildScriptUrl !== "string") {
throw new Error(
`--build-script must be of type 'string', ${typeof buildScriptUrl} given.`
);
}
} catch (err) {
logger.error(`Error occurred validating inputs for ${serviceName}`);
logger.error(err);
if (
!isValidConfig(
orgName,
devopsProject,
pipelineName,
repoName,
repoUrl,
buildScriptUrl,
personalAccessToken
)
) {
process.exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/validations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ lifecycle_pipeline_name="$mono_repo_dir-lifecycle"
pipeline_exists $AZDO_ORG_URL $AZDO_PROJECT $lifecycle_pipeline_name

# Deploy lifecycle pipeline and verify it runs.
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
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

# TODO: Verify the lifecycle pipeline sucessfully runs
# Verify lifecycle pipeline was created
Expand Down