0

我見過這樣的例子爲通過ebextensions配置創建和運行一個腳本:我是否可以在ebextensions中包含腳本而不必構建腳本?

files: 
    "C:\\scripts\\whoami.ps1": 
    content: | 
     date  | out-file -append c:\scripts\whoami.log 
     whoami  | out-file -append c:\scripts\whoami.log 
     hostname | out-file -append c:\scripts\whoami.log 
     get-module | out-file -append c:\scripts\whoami.log 

commands: 
    whoami: 
    command: powershell.exe -ExecutionPolicy Bypass -Command "C:\\scripts\\whoami.ps1" 
    ignoreErrors: false 
    waitAfterCompletion: 5 

這很好,但我能不能包括在ebextensions腳本和參考,而不必在定義其內容吧配置?

例如我會

myapp 
--.ebextensions 
----myconfig.config 
----myscript.ps1 

然後在 「myconfig.config」 將複製 「myscript.ps1」 的地方,並運行它。

我該怎麼做?

編輯: 所以我在配置把這個命令來查看當前的路徑是什麼:

commands: 
    whereami: 
    command: dir > c:\whereami.log 
    ignoreErrors: false 
    waitAfterCompletion: 5 

c:\windows\system32這是有道理的,因爲它在系統的上下文中運行。

是否沒有自我參照方法/關鍵字我可以用它來指向我已經位於我上傳的beanstalk項目中的腳本?

+0

您何時想要在應用程序部署時運行此腳本?它是否依賴於您的應用程序已被部署?你的應用程序部署是否依賴於已經運行的腳本?你需要訪問腳本中的環境變量嗎? – littleforest

+0

只想知道我可以如何在我的項目中放置一個腳本(甚至可能在.ebextensions文件夾內?),並通過ebextensions配置調用它 – red888

+0

您是否嘗試將文件存儲在主源代碼中,然後使用容器命令? – littleforest

回答

0

對我有用的選項(感謝littleforest)。

web部署包的內部創建一個文件夾結構,並且是指其與container_commands

package/myfolder/myscript.ps1 

container_commands: 
    relativeprogrampath: 
    command: "myfolder/myscript.ps1" 

在父文件夾中創建它,並參考它:

例如文件夾結構:

parentfolder/myfolder/myscript.ps1 
parentfolder/package/<the web deployment package> 

container_commands: 
    relativeprogrampath: 
    command: "..\myscript.ps1" 
相關問題