Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make deploy script path relative to package path and do not copy scri… #4095

Merged
merged 3 commits into from
Apr 24, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 3 additions & 9 deletions Tasks/PackerBuild/DefaultTemplates/custom.linux.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"storage_account": "{{env `storage_account`}}",
"image_url": "{{env `image_url`}}",
"location": "{{env `location`}}",
"script_path": "{{env `script_path`}}",
"script_name": "{{env `script_name`}}",
"script_relative_path": "{{env `script_relative_path`}}",
"script_arguments": "{{env `script_arguments`}}",
"package_path": "{{env `package_path`}}",
"package_name": "{{env `package_name`}}",
Expand Down Expand Up @@ -43,11 +42,6 @@
"chmod 777 /deployTemp"
]
},
{
"type": "file",
"source": "{{user `script_path`}}",
"destination": "/deployTemp/{{user `script_name`}}"
},
{
"type": "file",
"source": "{{user `package_path`}}",
Expand All @@ -59,8 +53,8 @@
"inline": [
"cd /deployTemp",
"ls",
"chmod +x /deployTemp/{{user `script_name`}}",
"/deployTemp/{{user `script_name`}} {{user `script_arguments`}}"
"chmod +x /deployTemp/{{user `package_name`}}/{{user `script_relative_path`}}",
"/deployTemp/{{user `package_name`}}/{{user `script_relative_path`}} {{user `script_arguments`}}"
]
},
{
Expand Down
10 changes: 2 additions & 8 deletions Tasks/PackerBuild/DefaultTemplates/custom.windows.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"storage_account": "{{env `storage_account`}}",
"image_url": "{{env `image_url`}}",
"location": "{{env `location`}}",
"script_path": "{{env `script_path`}}",
"script_name": "{{env `script_name`}}",
"script_relative_path": "{{env `script_relative_path`}}",
"script_arguments": "{{env `script_arguments`}}",
"package_path": "{{env `package_path`}}",
"package_name": "{{env `package_name`}}",
Expand Down Expand Up @@ -47,11 +46,6 @@
"cmd /c \"mkdir c:\\\\DeployTemp\""
]
},
{
"type": "file",
"source": "{{user `script_path`}}",
"destination": "c:\\DeployTemp\\{{user `script_name`}}"
},
{
"type": "file",
"source": "{{user `package_path`}}",
Expand All @@ -62,7 +56,7 @@
"inline": [
"cd \"C:\\DeployTemp\"",
"ls",
"C:\\DeployTemp\\{{user `script_name`}} {{user `script_arguments`}}"
"C:\\DeployTemp\\{{user `package_name`}}\\{{user `script_relative_path`}} {{user `script_arguments`}}"
]
},
{
Expand Down
12 changes: 3 additions & 9 deletions Tasks/PackerBuild/DefaultTemplates/default.linux.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"image_offer": "",
"image_sku": "",
"location": "",
"script_path": "",
"script_name": "",
"script_relative_path": "",
"script_arguments": "",
"package_path": "",
"package_name": "",
Expand Down Expand Up @@ -47,11 +46,6 @@
"chmod 777 /deployTemp"
]
},
{
"type": "file",
"source": "{{user `script_path`}}",
"destination": "/deployTemp/{{user `script_name`}}"
},
{
"type": "file",
"source": "{{user `package_path`}}",
Expand All @@ -63,8 +57,8 @@
"inline": [
"cd /deployTemp",
"ls",
"chmod +x /deployTemp/{{user `script_name`}}",
"/deployTemp/{{user `script_name`}} {{user `script_arguments`}}"
"chmod +x /deployTemp/{{user `package_name`}}/{{user `script_relative_path`}}",
"/deployTemp/{{user `package_name`}}/{{user `script_relative_path`}} {{user `script_arguments`}}"
]
},
{
Expand Down
10 changes: 2 additions & 8 deletions Tasks/PackerBuild/DefaultTemplates/default.windows.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"image_offer": "",
"image_sku": "",
"location": "",
"script_path": "",
"script_name": "",
"script_relative_path": "",
"script_arguments": "",
"package_path": "",
"package_name": "",
Expand Down Expand Up @@ -51,11 +50,6 @@
"cmd /c \"mkdir c:\\\\DeployTemp\""
]
},
{
"type": "file",
"source": "{{user `script_path`}}",
"destination": "c:\\DeployTemp\\{{user `script_name`}}"
},
{
"type": "file",
"source": "{{user `package_path`}}",
Expand All @@ -66,7 +60,7 @@
"inline": [
"cd \"C:\\DeployTemp\"",
"ls",
"C:\\DeployTemp\\{{user `script_name`}} {{user `script_arguments`}}"
"C:\\DeployTemp\\{{user `package_name`}}\\{{user `script_relative_path`}} {{user `script_arguments`}}"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"loc.input.label.packagePath": "Application Package/folder",
"loc.input.help.packagePath": "Specify the path for application package relative to $(System.DefaultWorkingDirectory). Supports minimatch pattern.",
"loc.input.label.deployScriptPath": "Deployment script",
"loc.input.help.deployScriptPath": "Specify the path to powershell or shell script which deploys provided application package. Path should be relative to relative to $(System.DefaultWorkingDirectory). Supports minimatch pattern.",
"loc.input.help.deployScriptPath": "Specify the relative path to powershell script(for windows VMSS) or shell script(for linux VMSS) which deploys provided application package. Path should be relative to package path selected above. Supports minimatch pattern.",
"loc.input.label.deployScriptArguments": "Deployment script arguments",
"loc.input.help.deployScriptArguments": "Specify the arguments to be passed to deployment script.",
"loc.input.label.imageUri": "Image URL",
Expand Down
18 changes: 11 additions & 7 deletions Tasks/PackerBuild/Tests/L0Linux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ tr.setInput('storageAccountName', 'teststorage');
tr.setInput('baseImageSource', 'default');
tr.setInput('baseImage', 'Canonical:UbuntuServer:14.04.4-LTS:linux');
tr.setInput('location', 'South India');
tr.setInput('packagePath', '/packer-user-scripts/dummy.tar.gz');
tr.setInput('deployScriptPath', '/packer-user-scripts/deploy.sh');
tr.setInput('packagePath', 'dir1/**/dir2');
tr.setInput('deployScriptPath', 'dir3/**/deploy.sh');
tr.setInput('deployScriptArguments', "\"subdir 1\" false");
tr.setInput('ConnectedServiceName', 'AzureRMSpn');
tr.setInput('imageUri', 'imageUri');
Expand Down Expand Up @@ -43,23 +43,23 @@ let a: any = <any>{
"code": 0,
"stdout": "{ \"some-key\": \"some-value\" }"
},
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/default.linux.template-fixed.json": {
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/default.linux.template-fixed.json": {
"code": 0,
"stdout": "Executed Successfully"
},
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/default.linux.template-fixed.json": {
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/default.linux.template-fixed.json": {
"code": process.env["__packer_build_fails__"] === "true" ? 1 : 0,
"stdout": process.env["__packer_build_fails__"] === "true" ? "packer build failed\r\nsome error" : "Executed Successfully\nOSDiskUri: https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/packer/packer-osDisk.e2e08a75-2d73-49ad-97c2-77f8070b65f5.vhd\nStorageAccountLocation: SouthIndia",
},
"packer fix -validate=false \\tmp\\tempdir\\100\\default.linux.template.json": {
"code": 0,
"stdout": "Executed Successfully"
},
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\default.linux.template-fixed.json": {
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\default.linux.template-fixed.json": {
"code": 0,
"stdout": "Executed Successfully"
},
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\default.linux.template-fixed.json": {
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_publisher=Canonical -var image_offer=UbuntuServer -var image_sku=14.04.4-LTS -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\default.linux.template-fixed.json": {
"code": process.env["__packer_build_fails__"] === "true" ? 1 : 0,
"stdout": process.env["__packer_build_fails__"] === "true" ? "packer build failed\r\nsome error" : "Executed Successfully\nOSDiskUri: https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/packer/packer-osDisk.e2e08a75-2d73-49ad-97c2-77f8070b65f5.vhd\nStorageAccountLocation: SouthIndia",
}
Expand Down Expand Up @@ -94,7 +94,11 @@ tr.registerMock('./utilities', {
console.log("writing to file " + filePath + " content: " + content);
},
findMatch: function(root: string, patterns: string[] | string) {
return [patterns];
if(root === undefined) {
return ["/tmp/dir1/somedir/dir2"];
} else {
return ["/tmp/dir1/somedir/dir2/dir3/somedir/deploy.sh"];
}
},
getCurrentTime: function() {
return 100;
Expand Down
18 changes: 11 additions & 7 deletions Tasks/PackerBuild/Tests/L0LinuxCustomImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ tr.setInput('baseImageSource', 'customVhd');
tr.setInput('customImageUrl', 'https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd');
tr.setInput('customImageOSType', 'linux');
tr.setInput('location', 'South India');
tr.setInput('packagePath', '/packer-user-scripts/dummy.tar.gz');
tr.setInput('deployScriptPath', '/packer-user-scripts/deploy.sh');
tr.setInput('packagePath', 'dir1/**/dir2');
tr.setInput('deployScriptPath', 'dir3/**/deploy.sh');
tr.setInput('deployScriptArguments', "\"subdir 1\" false");
tr.setInput('ConnectedServiceName', 'AzureRMSpn');
tr.setInput('imageUri', 'imageUri');
Expand Down Expand Up @@ -44,23 +44,23 @@ let a: any = <any>{
"code": 0,
"stdout": "{ \"some-key\": \"some-value\" }"
},
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/custom.linux.template-fixed.json": {
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/custom.linux.template-fixed.json": {
"code": 0,
"stdout": "Executed Successfully"
},
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/custom.linux.template-fixed.json": {
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId /tmp/tempdir/100/custom.linux.template-fixed.json": {
"code": process.env["__packer_build_fails__"] === "true" ? 1 : 0,
"stdout": process.env["__packer_build_fails__"] === "true" ? "packer build failed\r\nsome error" : "Executed Successfully\nOSDiskUri: https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/packer/packer-osDisk.e2e08a75-2d73-49ad-97c2-77f8070b65f5.vhd\nStorageAccountLocation: SouthIndia",
},
"packer fix -validate=false \\tmp\\tempdir\\100\\custom.linux.template.json": {
"code": 0,
"stdout": "Executed Successfully"
},
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\custom.linux.template-fixed.json": {
"packer validate -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\custom.linux.template-fixed.json": {
"code": 0,
"stdout": "Executed Successfully"
},
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_path=/packer-user-scripts/deploy.sh -var script_name=deploy.sh -var package_path=/packer-user-scripts/dummy.tar.gz -var package_name=dummy.tar.gz -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\custom.linux.template-fixed.json": {
"packer build -force -var resource_group=testrg -var storage_account=teststorage -var image_url=https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/vsts-buildimagetask/Release-1-osDisk.2d175222-b257-405f-a07f-0af4dc4b3dc4.vhd -var location=South India -var capture_name_prefix=Release-1 -var script_relative_path=dir3/somedir/deploy.sh -var package_path=/tmp/dir1/somedir/dir2 -var package_name=dir2 -var script_arguments=\"subdir 1\" false -var subscription_id=sId -var client_id=spId -var client_secret=spKey -var tenant_id=tenant -var object_id=oId \\tmp\\tempdir\\100\\custom.linux.template-fixed.json": {
"code": process.env["__packer_build_fails__"] === "true" ? 1 : 0,
"stdout": process.env["__packer_build_fails__"] === "true" ? "packer build failed\r\nsome error" : "Executed Successfully\nOSDiskUri: https://bishalpackerimages.blob.core.windows.net/system/Microsoft.Compute/Images/packer/packer-osDisk.e2e08a75-2d73-49ad-97c2-77f8070b65f5.vhd\nStorageAccountLocation: SouthIndia",
}
Expand Down Expand Up @@ -99,7 +99,11 @@ tr.registerMock('./utilities', {
console.log("writing to file " + filePath + " content: " + content);
},
findMatch: function(root: string, patterns: string[] | string) {
return [patterns];
if(root === undefined) {
return ["/tmp/dir1/somedir/dir2"];
} else {
return ["/tmp/dir1/somedir/dir2/dir3/somedir/deploy.sh"];
}
},
getCurrentTime: function() {
return 100;
Expand Down
Loading