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" 
相关问题