2017-06-26 21 views
0

我在VSTS中使用用戶提供的Packer模板構建自定義Azure ami以部署到VMSS(類似於此處指示的link用戶提供的Packer模板在VSTS中構建不可變映像

在我的打包模板的供應商部分,有一個名爲Deploy的文件夾(與模板位於同一目錄中)需要上傳,其中包含由打包程序供應商運行以創建自定義映像的所有腳本和證書。

"provisioners": [ 
{ 
    "type": "windows-shell", 
    "inline": [ 
     "cmd /c \"mkdir c:\\\\PackerTemp\"" 
    ] 
}, 
{ 
    "type": "file", 
    "source": "./Deploy", 
    "destination": "c:\\PackerTemp" 
}, 
{ 
    "type": "powershell", 
    "inline": [ 
     "Start-Process powershell -ArgumentList \"C:\\\\PackerTemp\\\\Deploy\\\\InstallIIS.ps1\" -NoNewWindow -Wait" 
    ] 
}, 
{ 
    "type": "powershell", 
    "inline": [ 
     "Start-Process powershell -ArgumentList \"C:\\\\PackerTemp\\\\Deploy\\\\InstallCertificate.ps1\" -NoNewWindow -Wait" 
    ] 
} 

上面的工作很好,當地方建設。但是,使用VSTS進行構建時,VSTS僅將模板文件複製到臨時位置,並從臨時位置執行,而不實際複製整個目錄。

2017-06-26T04:16:15.4579904Z Original template location: 
d:\a\r1\a\PackerExperiment\drop\PackerTemplate\firstPackerTry.json 
2017-06-26T04:16:15.4579904Z Copying original template from 
d:\a\r1\a\PackerExperiment\drop\PackerTemplate\firstPackerTry.json to 
temporary location d:\a\_temp\1498450573956 
2017-06-26T04:16:15.4599904Z Copied template file to a temporary location: 
d:\a\_temp\1498450573956 

因此,形象建設任務失敗,出現錯誤

* Bad source './Deploy': GetFileAttributesEx ./Deploy: The system cannot find the file specified. 

我找不到太多的信息。有沒有解決這個問題的方法?我是VSTS和派克的新手

任何幫助/建議將不勝感激。

+0

您是否參考此博客:https://blogs.msdn.microsoft.com/manibindra/2016/12/26/how-to-continuously-deploy-web-application-to-azure-vm-scale- sets-using-vsts-and-packer/ –

回答

0

構建任務現在只複製模板文件,沒有設置將其配置爲將其他文件夾/文件複製在一起。

解決方法是在構建定義中添加「複製文件」任務,以便在「構建不可變映像」任務運行之前將「部署」文件夾複製到「d:\ a_temp」文件夾中。

+0

這對我來說並不適合。在本地結束使用打包程序來創建安裝了所有必需功能的基本映像,因爲它們很少會更改。由於打包者將基本映像vhd存儲在存儲帳戶中,因此在自動生成的打包程序模板中將vhd url作爲自定義映像傳遞,以嵌入執行技巧的工件。 – apurva

相關問題