Skip to content

Commit 018c7dd

Browse files
author
Rajat Agrawal
committed
Merge branch 'releases/m106' of https://github.com/Microsoft/vsts-tasks into releases/m106
2 parents 2c4df48 + 8e9c5cb commit 018c7dd

File tree

33 files changed

+370
-320
lines changed

33 files changed

+370
-320
lines changed

Tasks/Gradle/CodeAnalysis/Common/CodeAnalysisOrchestrator.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,24 @@ export class CodeAnalysisOrchestrator {
2727
}
2828

2929
public configureBuild(toolRunner: ToolRunner): ToolRunner {
30-
for (var tool of this.tools) {
31-
toolRunner = tool.configureBuild(toolRunner);
32-
}
3330

31+
if (this.checkBuildContext()) {
32+
for (var tool of this.tools) {
33+
toolRunner = tool.configureBuild(toolRunner);
34+
}
35+
}
36+
3437
return toolRunner;
3538
}
3639

3740
/**
3841
* Parses the code analysis tool results (PMD, CheckStyle .. but not SonarQube). Uploads reports and artifacts.
3942
*/
40-
public publishCodeAnalysisResults():void {
43+
public publishCodeAnalysisResults(): void {
4144

42-
tl.debug(`[CA] Attempting to find report files from ${this.tools.length} code analysis tool(s)`);
45+
if (this.checkBuildContext() && this.tools.length > 0) {
46+
tl.debug(`[CA] Attempting to find report files from ${this.tools.length} code analysis tool(s)`);
4347

44-
if (this.tools.length > 0) {
4548
let stagingDir = path.join(tl.getVariable('build.artifactStagingDirectory'), ".codeAnalysis");
4649
let buildNumber: string = tl.getVariable('build.buildNumber');
4750

@@ -54,17 +57,30 @@ export class CodeAnalysisOrchestrator {
5457
}
5558
}
5659

57-
private processResults(tools: IAnalysisTool[]):AnalysisResult[] {
60+
private processResults(tools: IAnalysisTool[]): AnalysisResult[] {
5861

5962
let analysisResults: AnalysisResult[] = [];
6063

6164
for (var tool of tools) {
62-
var results = tool.processResults();
65+
var results: AnalysisResult[] = tool.processResults();
6366
if (results) {
6467
analysisResults = analysisResults.concat(results);
6568
}
6669
}
6770

6871
return analysisResults;
6972
}
73+
74+
private checkBuildContext(): boolean {
75+
let requiredVariables: string[] = ['build.sourcesDirectory', 'build.artifactStagingDirectory', 'build.buildNumber'];
76+
77+
for (var requiredVariable of requiredVariables) {
78+
if (!tl.getVariable(requiredVariable)) {
79+
console.log(tl.loc('codeAnalysisDisabled', requiredVariable));
80+
return false;
81+
}
82+
}
83+
84+
return true;
85+
}
7086
}

Tasks/Gradle/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"loc.messages.codeAnalysisBuildSummaryLine_NoViolations": "%s found no violations.",
8989
"loc.messages.codeAnalysisBuildSummaryTitle": "Code Analysis Report",
9090
"loc.messages.codeAnalysisArtifactSummaryTitle": "Code Analysis Results",
91+
"loc.messages.codeAnalysisDisabled": "Code analysis is disabled outside of the build enviroment. Could not find a value for: %s",
9192
"loc.messages.LocateJVMBasedOnVersionAndArch": "Locate JAVA_HOME for Java %s %s",
9293
"loc.messages.FailedToLocateSpecifiedJVM": "Failed to find specified JDK version. Please make sure environment variable '%s' exists and is set to the location of a corresponding JDK."
9394
}

Tasks/Gradle/task.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"version": {
1313
"Major": 1,
1414
"Minor": 0,
15-
"Patch": 61
15+
"Patch": 62
1616
},
1717
"demands": [
1818
"java"
@@ -352,7 +352,8 @@
352352
"codeAnalysisBuildSummaryLine_NoViolations": "%s found no violations.",
353353
"codeAnalysisBuildSummaryTitle": "Code Analysis Report",
354354
"codeAnalysisArtifactSummaryTitle": "Code Analysis Results",
355+
"codeAnalysisDisabled": "Code analysis is disabled outside of the build enviroment. Could not find a value for: %s",
355356
"LocateJVMBasedOnVersionAndArch": "Locate JAVA_HOME for Java %s %s",
356357
"FailedToLocateSpecifiedJVM": "Failed to find specified JDK version. Please make sure environment variable '%s' exists and is set to the location of a corresponding JDK."
357358
}
358-
}
359+
}

Tasks/Gradle/task.loc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"version": {
1313
"Major": 1,
1414
"Minor": 0,
15-
"Patch": 61
15+
"Patch": 62
1616
},
1717
"demands": [
1818
"java"
@@ -352,6 +352,7 @@
352352
"codeAnalysisBuildSummaryLine_NoViolations": "ms-resource:loc.messages.codeAnalysisBuildSummaryLine_NoViolations",
353353
"codeAnalysisBuildSummaryTitle": "ms-resource:loc.messages.codeAnalysisBuildSummaryTitle",
354354
"codeAnalysisArtifactSummaryTitle": "ms-resource:loc.messages.codeAnalysisArtifactSummaryTitle",
355+
"codeAnalysisDisabled": "ms-resource:loc.messages.codeAnalysisDisabled",
355356
"LocateJVMBasedOnVersionAndArch": "ms-resource:loc.messages.LocateJVMBasedOnVersionAndArch",
356357
"FailedToLocateSpecifiedJVM": "ms-resource:loc.messages.FailedToLocateSpecifiedJVM"
357358
}

Tasks/ManualIntervention/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"loc.friendlyName": "Manual Intervention",
3-
"loc.helpMarkDown": "[More Information](https://www.visualstudio.com/docs/build/steps/deploy/manual-intervention/)",
3+
"loc.helpMarkDown": "[More Information](http://go.microsoft.com/fwlink/?LinkID=825235)",
44
"loc.description": "Pause deployment and wait for intervention",
55
"loc.instanceNameFormat": "Manual Intervention",
66
"loc.input.label.instructions": "Instructions",

Tasks/ManualIntervention/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "ManualIntervention",
44
"friendlyName": "Manual Intervention",
55
"description": "Pause deployment and wait for intervention",
6-
"helpMarkDown": "[More Information](https://www.visualstudio.com/docs/build/steps/deploy/manual-intervention/)",
6+
"helpMarkDown": "[More Information](http://go.microsoft.com/fwlink/?LinkID=825235)",
77
"category": "Deploy",
88
"visibility": [
99
"Release"
@@ -15,7 +15,7 @@
1515
"version": {
1616
"Major": 8,
1717
"Minor": 0,
18-
"Patch": 0
18+
"Patch": 1
1919
},
2020
"inputs": [
2121
{

Tasks/ManualIntervention/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"version": {
1616
"Major": 8,
1717
"Minor": 0,
18-
"Patch": 0
18+
"Patch": 1
1919
},
2020
"inputs": [
2121
{
@@ -36,4 +36,4 @@
3636
"execution": {
3737
"RM:ManualIntervention": {}
3838
}
39-
}
39+
}

Tasks/Maven/CodeAnalysis/Common/CodeAnalysisOrchestrator.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,24 @@ export class CodeAnalysisOrchestrator {
2727
}
2828

2929
public configureBuild(toolRunner: ToolRunner): ToolRunner {
30-
for (var tool of this.tools) {
31-
toolRunner = tool.configureBuild(toolRunner);
32-
}
3330

31+
if (this.checkBuildContext()) {
32+
for (var tool of this.tools) {
33+
toolRunner = tool.configureBuild(toolRunner);
34+
}
35+
}
36+
3437
return toolRunner;
3538
}
3639

3740
/**
3841
* Parses the code analysis tool results (PMD, CheckStyle .. but not SonarQube). Uploads reports and artifacts.
3942
*/
40-
public publishCodeAnalysisResults():void {
43+
public publishCodeAnalysisResults(): void {
4144

42-
tl.debug(`[CA] Attempting to find report files from ${this.tools.length} code analysis tool(s)`);
45+
if (this.checkBuildContext() && this.tools.length > 0) {
46+
tl.debug(`[CA] Attempting to find report files from ${this.tools.length} code analysis tool(s)`);
4347

44-
if (this.tools.length > 0) {
4548
let stagingDir = path.join(tl.getVariable('build.artifactStagingDirectory'), ".codeAnalysis");
4649
let buildNumber: string = tl.getVariable('build.buildNumber');
4750

@@ -54,17 +57,30 @@ export class CodeAnalysisOrchestrator {
5457
}
5558
}
5659

57-
private processResults(tools: IAnalysisTool[]):AnalysisResult[] {
60+
private processResults(tools: IAnalysisTool[]): AnalysisResult[] {
5861

5962
let analysisResults: AnalysisResult[] = [];
6063

6164
for (var tool of tools) {
62-
var results = tool.processResults();
65+
var results: AnalysisResult[] = tool.processResults();
6366
if (results) {
6467
analysisResults = analysisResults.concat(results);
6568
}
6669
}
6770

6871
return analysisResults;
6972
}
73+
74+
private checkBuildContext(): boolean {
75+
let requiredVariables: string[] = ['build.sourcesDirectory', 'build.artifactStagingDirectory', 'build.buildNumber'];
76+
77+
for (var requiredVariable of requiredVariables) {
78+
if (!tl.getVariable(requiredVariable)) {
79+
console.log(tl.loc('codeAnalysisDisabled', requiredVariable));
80+
return false;
81+
}
82+
}
83+
84+
return true;
85+
}
7086
}

Tasks/Maven/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"loc.messages.codeAnalysisBuildSummaryLine_NoViolations": "%s found no violations.",
9191
"loc.messages.codeAnalysisBuildSummaryTitle": "Code Analysis Report",
9292
"loc.messages.codeAnalysisArtifactSummaryTitle": "Code Analysis Results",
93+
"loc.messages.codeAnalysisDisabled": "Code analysis is disabled outside of the build enviroment. Could not find a value for: %s",
9394
"loc.messages.LocateJVMBasedOnVersionAndArch": "Locate JAVA_HOME for Java %s %s",
9495
"loc.messages.FailedToLocateSpecifiedJVM": "Failed to find specified JDK version. Please make sure environment variable '%s' exists and is set to the location of a corresponding JDK."
9596
}

Tasks/Maven/task.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"version": {
1717
"Major": 1,
1818
"Minor": 0,
19-
"Patch": 68
19+
"Patch": 69
2020
},
2121
"minimumAgentVersion": "1.89.0",
2222
"instanceNameFormat": "Maven $(mavenPOMFile)",
@@ -368,6 +368,7 @@
368368
"codeAnalysisBuildSummaryLine_NoViolations": "%s found no violations.",
369369
"codeAnalysisBuildSummaryTitle": "Code Analysis Report",
370370
"codeAnalysisArtifactSummaryTitle": "Code Analysis Results",
371+
"codeAnalysisDisabled": "Code analysis is disabled outside of the build enviroment. Could not find a value for: %s",
371372
"LocateJVMBasedOnVersionAndArch": "Locate JAVA_HOME for Java %s %s",
372373
"FailedToLocateSpecifiedJVM": "Failed to find specified JDK version. Please make sure environment variable '%s' exists and is set to the location of a corresponding JDK."
373374

0 commit comments

Comments
 (0)