Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

Create and Install Data Package Tasks #174

Merged
merged 9 commits into from
Oct 15, 2020
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
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"**/node_modules":true,
"packages/azpipelines/build":true,
"**/lib":true
}
}
},
"editor.tabSize": 2
}
6 changes: 3 additions & 3 deletions build_templates/azpipelines-dev.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Milestone17$(Rev:.r)
name: Milestone18$(Rev:.r)



variables:
- group: Tokens
- name: major
value: 17
value: 18

- name: minor
value: $[counter(variables['major'], 200)]
Expand Down Expand Up @@ -57,4 +57,4 @@ stages:
displayName: 'Install the new version of the plugin'
inputs:
script: |
az devops extension install --extension-id sfpowerscripts-dev --publisher-id AzlamSalam --org https://dev.azure.com/safebot
az devops extension install --extension-id sfpowerscripts-dev --publisher-id AzlamSalam --org https://dev.azure.com/safebot
2 changes: 2 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"packages/azpipelines/BuildTasks/AnalyzeWithPMDTask",
"packages/azpipelines/BuildTasks/AuthenticateOrgTaskCurrent",
"packages/azpipelines/BuildTasks/CheckoutProjectFromArtifactTask",
"packages/azpipelines/BuildTasks/CreateDataPackageTask",
"packages/azpipelines/BuildTasks/CreateDeltaPackageTask",
"packages/azpipelines/BuildTasks/CreateSourcePackageTask",
"packages/azpipelines/BuildTasks/CreateUnlockedPackageTask",
Expand All @@ -16,6 +17,7 @@
"packages/azpipelines/BuildTasks/IncrementProjectBuildNumberTask",
"packages/azpipelines/BuildTasks/InstallPackageDependenciesTask",
"packages/azpipelines/BuildTasks/InstallSFDXCLITaskCurrent",
"packages/azpipelines/BuildTasks/InstallDataPackageTask",
"packages/azpipelines/BuildTasks/InstallUnlockedPackageTask",
"packages/azpipelines/BuildTasks/InstallSourcePackageTask",
"packages/azpipelines/BuildTasks/ManageScratchOrgTaskCurrent",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import tl = require("azure-pipelines-task-lib/task");
import PackageDiffImpl from "@dxatscale/sfpowerscripts.core/lib/package/PackageDiffImpl";
import CreateDataPackageImpl from "@dxatscale/sfpowerscripts.core/lib/sfdxwrappers/CreateDataPackageImpl";
import PackageMetadata from "@dxatscale/sfpowerscripts.core/lib/PackageMetadata";
import ArtifactGenerator from "@dxatscale/sfpowerscripts.core/lib/generators/ArtifactGenerator"



async function run() {
try {
let sfdx_package: string = tl.getInput("package", true);
let version_number: string = tl.getInput("version_number", false);
let isDiffCheck: boolean = tl.getBoolInput("isDiffCheck", false);
let isGitTag: boolean = tl.getBoolInput("isGitTag", false);
let projectDirectory: string = tl.getInput("project_directory", false);
let commitId = tl.getVariable("build.sourceVersion");
let repositoryUrl = tl.getVariable("build.repository.uri");

let isRunBuild: boolean;
if (isDiffCheck) {
let packageDiffImpl = new PackageDiffImpl(
sfdx_package,
projectDirectory
);

isRunBuild = await packageDiffImpl.exec();

if (isRunBuild)
console.log(
`Detected changes to ${sfdx_package} package...proceeding\n`
);
else
console.log(
`No changes detected for ${sfdx_package} package...skipping\n`
);
} else isRunBuild = true;

if (isRunBuild) {
//Create Metadata Artifact
let packageMetadata:PackageMetadata = {
package_name: sfdx_package,
package_version_number: version_number,
sourceVersion: commitId,
repository_url: repositoryUrl
};


let createDataPackageImpl: CreateDataPackageImpl = new CreateDataPackageImpl(
projectDirectory,
sfdx_package,
packageMetadata
);
packageMetadata = await createDataPackageImpl.exec();


console.log("##[command]Package Metadata:"+JSON.stringify(packageMetadata));


let artifact= await ArtifactGenerator.generateArtifact(sfdx_package,projectDirectory,tl.getVariable("agent.tempDirectory"),packageMetadata);

tl.uploadArtifact(`${sfdx_package}_sfpowerscripts_artifact`, artifact.artifactDirectory,`${sfdx_package}_sfpowerscripts_artifact`);




tl.setVariable("sfpowerscripts_package_version_number", version_number);
tl.setVariable(
"sfpowerscripts_data_package_metadata_path",
artifact.artifactMetadataFilePath
);
tl.setVariable(
"sfpowerscripts_data_package_path",
artifact.artifactSourceDirectory
);


//Create Git Tag
if (isGitTag) {
let tagname: string = `${sfdx_package}_v${version_number}`;
tl.setVariable(`${sfdx_package}_sfpowerscripts_git_tag`, tagname);
if (projectDirectory == null)
tl.setVariable(
`${sfdx_package}_sfpowerscripts_project_directory_path`,
tl.getVariable("Build.Repository.LocalPath")
);
else
tl.setVariable(
`${sfdx_package}_sfpowerscripts_project_directory_path`,
projectDirectory
);
}
}
} catch (err) {
tl.setResult(tl.TaskResult.Failed, err.message);
}
}

run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import tl = require("azure-pipelines-task-lib/task");

async function run() {
const isGitTag: boolean = tl.getBoolInput("isGitTag", false);
const sfdx_package: string = tl.getInput("package", true);

if (isGitTag) {
console.log(
`Checking whether Post Package Create Task is added to the pipeline as ${isGitTag} is enabled for ${sfdx_package}`
);
let isPostPackageTaskExecuted: string = tl.getVariable(
"post_package_task_executed"
);

if (isPostPackageTaskExecuted != "true") {
tl.setResult(
tl.TaskResult.SucceededWithIssues,
`Post Package Task not executed/added in the pipeline, Please add it at the end of package creation commands!`
);
}
}
}

run();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading