Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
artifact filter
Browse files Browse the repository at this point in the history
  • Loading branch information
jabbera committed Feb 6, 2018
1 parent a9a0b73 commit bba765f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Tasks/common/GitRefCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export abstract class GitRefCreator {
return 1;
});

artifacts = this.filterIncludedArtifacts(artifacts);

let i: number;
for (i = 1; i < artifacts.length; i++) {
const prev: IArtifactData = artifacts[i - 1];
Expand Down Expand Up @@ -178,6 +180,25 @@ export abstract class GitRefCreator {
return artifacts;
}

private filterIncludedArtifacts(artifacts: IArtifactData[]): IArtifactData[] {
const includeMultiline: string[] = tl.getDelimitedInput("artifactIncludeList", "\r", false);
let includedArtifacts: Set<string>;

if (includeMultiline === null || includeMultiline.length === 0) {
tl.debug("inlcuding all artifacts");
includedArtifacts = new Set<string>(artifacts.map((x) => x.name));
}
else {
tl.debug("Filtering artifacts");
includedArtifacts = new Set<string>(includeMultiline);
}

tl.debug(`Before filter count: ${artifacts.length}`);
artifacts = artifacts.filter( (value) => includedArtifacts.has(value.name));
tl.debug(`After filter count ${artifacts.length}`);
return artifacts;
}

private async getRepositoryId(bldapi: bld.IBuildApi, name: string): Promise < string > {
let repositoryidVariable: string = `RELEASE.ARTIFACTS.${name}.REPOSITORY_ID`;
let repositoryid: string = tl.getVariable(repositoryidVariable);
Expand Down
9 changes: 9 additions & 0 deletions Tasks/git-branch-on-release-task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@
"required": false,
"helpMarkDown": "The replacement patten corresponding to the regex above. Default is empty string",
"groupName": "advanced"
},
{
"name": "artifactIncludeList",
"type": "multiLine",
"label": "Artifacts to include",
"defaultValue": "",
"required": false,
"helpMarkDown": "An optional list of artifacts to include. If empty, use all. Newline delimited.",
"groupName": "advanced"
}
],
"execution": {
Expand Down
9 changes: 9 additions & 0 deletions Tasks/git-tag-on-release-task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@
"required": false,
"helpMarkDown": "The replacement patten corresponding to the regex above. Default is empty string",
"groupName": "advanced"
},
{
"name": "artifactIncludeList",
"type": "multiLine",
"label": "Artifacts to include",
"defaultValue": "",
"required": false,
"helpMarkDown": "An optional list of artifacts to include. If empty, use all. Newline delimited.",
"groupName": "advanced"
}
],
"execution": {
Expand Down
3 changes: 2 additions & 1 deletion overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ Branching:

The branch folder allows you to specify a subfolder to branch to. Adding to the example above. If the Branch Folder was set to: 'patch' the ref that would be created is: /refs/heads/patch/v3.0.17270.8

* Changes in 5.0.0
* Changes in 5.0.X
* Support multiple artifcats from the same repository with different commits. Newest to be commited wins.
* Support an artifact filter if you need to include only a subset of artifacts.
* Changes in 4.0.1
* Update the error log to include previous commit id
* Changes in 4.0.0
Expand Down

0 comments on commit bba765f

Please sign in to comment.