Skip to content

Commit 8947d18

Browse files
2073393 ID 1.1.1 (AzDO) - Update PackerBuild@1 task to support Worklo… (#19835)
* 2073393 ID 1.1.1 (AzDO) - Update PackerBuild@1 task to support Workload Identity federation * Test case Failure * Test case Failure fixed
1 parent 5278dc6 commit 8947d18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1404
-1426
lines changed

Tasks/PackerBuildV1/DefaultTemplates/custom.linux.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "{{env `client_id`}}",
44
"client_secret": "{{env `client_secret`}}",
5+
"client_jwt": "{{env `client_jwt`}}",
56
"subscription_id": "{{env `subscription_id`}}",
67
"tenant_id": "{{env `tenant_id`}}",
78
"object_id": "{{env `object_id`}}",
@@ -20,6 +21,7 @@
2021
"type": "azure-arm",
2122
"client_id": "{{user `client_id`}}",
2223
"client_secret": "{{user `client_secret`}}",
24+
"client_jwt": "{{user `client_jwt`}}",
2325
"resource_group_name": "{{user `resource_group`}}",
2426
"storage_account": "{{user `storage_account`}}",
2527
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/DefaultTemplates/custom.managed.linux.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "{{env `client_id`}}",
44
"client_secret": "{{env `client_secret`}}",
5+
"client_jwt": "{{env `client_jwt`}}",
56
"subscription_id": "{{env `subscription_id`}}",
67
"tenant_id": "{{env `tenant_id`}}",
78
"object_id": "{{env `object_id`}}",
@@ -21,6 +22,7 @@
2122
"type": "azure-arm",
2223
"client_id": "{{user `client_id`}}",
2324
"client_secret": "{{user `client_secret`}}",
25+
"client_jwt": "{{user `client_jwt`}}",
2426
"managed_image_resource_group_name": "{{user `resource_group`}}",
2527
"managed_image_name": "{{user `managed_image_name`}}",
2628
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/DefaultTemplates/custom.managed.windows.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "{{env `client_id`}}",
44
"client_secret": "{{env `client_secret`}}",
5+
"client_jwt": "{{env `client_jwt`}}",
56
"subscription_id": "{{env `subscription_id`}}",
67
"tenant_id": "{{env `tenant_id`}}",
78
"object_id": "{{env `object_id`}}",
@@ -20,6 +21,7 @@
2021
"type": "azure-arm",
2122
"client_id": "{{user `client_id`}}",
2223
"client_secret": "{{user `client_secret`}}",
24+
"client_jwt": "{{user `client_jwt`}}",
2325
"managed_image_resource_group_name": "{{user `resource_group`}}",
2426
"managed_image_name": "{{user `managed_image_name`}}",
2527
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/DefaultTemplates/custom.windows.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "{{env `client_id`}}",
44
"client_secret": "{{env `client_secret`}}",
5+
"client_jwt": "{{env `client_jwt`}}",
56
"subscription_id": "{{env `subscription_id`}}",
67
"tenant_id": "{{env `tenant_id`}}",
78
"object_id": "{{env `object_id`}}",
@@ -19,6 +20,7 @@
1920
"type": "azure-arm",
2021
"client_id": "{{user `client_id`}}",
2122
"client_secret": "{{user `client_secret`}}",
23+
"client_jwt": "{{user `client_jwt`}}",
2224
"resource_group_name": "{{user `resource_group`}}",
2325
"storage_account": "{{user `storage_account`}}",
2426
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/DefaultTemplates/default.linux.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "",
44
"client_secret": "",
5+
"client_jwt": "",
56
"subscription_id": "",
67
"tenant_id": "",
78
"object_id": "",
@@ -22,6 +23,7 @@
2223
"type": "azure-arm",
2324
"client_id": "{{user `client_id`}}",
2425
"client_secret": "{{user `client_secret`}}",
26+
"client_jwt": "{{user `client_jwt`}}",
2527
"resource_group_name": "{{user `resource_group`}}",
2628
"storage_account": "{{user `storage_account`}}",
2729
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/DefaultTemplates/default.managed.linux.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "",
44
"client_secret": "",
5+
"client_jwt": "",
56
"subscription_id": "",
67
"tenant_id": "",
78
"object_id": "",
@@ -23,6 +24,7 @@
2324
"type": "azure-arm",
2425
"client_id": "{{user `client_id`}}",
2526
"client_secret": "{{user `client_secret`}}",
27+
"client_jwt": "{{user `client_jwt`}}",
2628
"managed_image_resource_group_name": "{{user `resource_group`}}",
2729
"managed_image_name": "{{user `managed_image_name`}}",
2830
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/DefaultTemplates/default.managed.windows.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "",
44
"client_secret": "",
5+
"client_jwt": "",
56
"subscription_id": "",
67
"tenant_id": "",
78
"object_id": "",
@@ -22,6 +23,7 @@
2223
"type": "azure-arm",
2324
"client_id": "{{user `client_id`}}",
2425
"client_secret": "{{user `client_secret`}}",
26+
"client_jwt": "{{user `client_jwt`}}",
2527
"managed_image_resource_group_name": "{{user `resource_group`}}",
2628
"managed_image_name": "{{user `managed_image_name`}}",
2729
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/DefaultTemplates/default.windows.template.json

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"variables": {
33
"client_id": "",
44
"client_secret": "",
5+
"client_jwt": "",
56
"subscription_id": "",
67
"tenant_id": "",
78
"object_id": "",
@@ -21,6 +22,7 @@
2122
"type": "azure-arm",
2223
"client_id": "{{user `client_id`}}",
2324
"client_secret": "{{user `client_secret`}}",
25+
"client_jwt": "{{user `client_jwt`}}",
2426
"resource_group_name": "{{user `resource_group`}}",
2527
"storage_account": "{{user `storage_account`}}",
2628
"subscription_id": "{{user `subscription_id`}}",

Tasks/PackerBuildV1/Tests/L0.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ describe('PackerBuild Suite V1', function() {
284284
process.env["__ostype__"] = "windows";
285285

286286
assert(tr.failed, 'task should have failed');
287-
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_OSTypeNotSupported") != -1, "error message should be right");
287+
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_OSTypeNotSupported") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]loc_mock_OSTypeNotSupported") != -1, "error message should be right");
288288
done();
289289
});
290290

@@ -365,7 +365,7 @@ describe('PackerBuild Suite V1', function() {
365365
assert(tr.failed, 'task should fail if output is not parsed properly');
366366
assert(tr.invokedToolCount == 4, 'all 4 commands should have been invoked. actual: ' + tr.invokedToolCount);
367367
assert(tr.stdout.indexOf("##vso[task.setvariable variable=imageUri;isOutput=false;issecret=false;]") == -1, "should not try to set output variable");
368-
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_ImageURIOutputVariableNotFound") != -1, "should show proper console message");
368+
assert(tr.stdout.indexOf("##vso[task.issue type=error;]loc_mock_ImageURIOutputVariableNotFound") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]loc_mock_ImageURIOutputVariableNotFound") != -1, "should show proper console message");
369369
done();
370370
});
371371

@@ -496,7 +496,7 @@ describe('PackerBuild Suite V1', function() {
496496

497497
assert(tr.invokedToolCount == 1, 'should have invoked tool only once. actual: ' + tr.invokedToolCount);
498498
assert(tr.failed, 'task should fail if download fails');
499-
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer download failed!!") != -1, "error message should be right");
499+
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer download failed!!") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]packer download failed!!") != -1, "error message should be right");
500500
done();
501501
});
502502

@@ -510,7 +510,7 @@ describe('PackerBuild Suite V1', function() {
510510

511511
assert(tr.invokedToolCount == 0, 'should have invoked tool not even once. actual: ' + tr.invokedToolCount);
512512
assert(tr.failed, 'task should fail if extraction fails');
513-
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer zip extraction failed!!") != -1, "error message should be right");
513+
assert(tr.stdout.indexOf("##vso[task.issue type=error;]packer zip extraction failed!!") != -1 || tr.stdout.indexOf("##vso[task.issue type=error;source=TaskInternal;]packer zip extraction failed!!") != -1, "error message should be right");
514514
done();
515515
});
516516

Tasks/PackerBuildV1/Tests/L0Utilities.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ma = require('azure-pipelines-task-lib/mock-answer');
22
import tmrm = require('azure-pipelines-task-lib/mock-run');
33
import path = require('path');
4-
var mockery = require('mockery');
4+
import * as libMocker from 'azure-pipelines-task-lib/lib-mocker';
55

66
// provide answers for task mock
77
let a: any = <any>{
@@ -18,10 +18,10 @@ let a: any = <any>{
1818
}
1919
};
2020

21-
mockery.enable({warnOnUnregistered: false});
21+
libMocker.enable({warnOnUnregistered: false});
2222
var tlm = require('azure-pipelines-task-lib/mock-task');
2323
tlm.setAnswers(a);
24-
mockery.registerMock('azure-pipelines-task-lib/task', tlm);
24+
libMocker.registerMock('azure-pipelines-task-lib/task', tlm);
2525
var ut = require('../src/utilities.js');
2626

2727
ut.copyFile(".\\DefaultTemplates\\default.windows.template.json", "F:\\somedir\\tempdir\\100");

0 commit comments

Comments
 (0)