AWS CodeDeploy
User Guide (API Version 2014-10-06)
AWS 服务或AWS文档中描述的功能,可能因地区/位置而异。点 击 Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

AppSpec 的“files”部分

向 AWS CodeDeploy 提供以下相关信息:部署的 Install 事件期间应安装在实例上的应用程序修订中的文件。仅当您要在部署期间将修订中的文件复制到实例上的位置时,才需要此部分。

此部分具有以下结构:

Copy
files: - source: source-file-location destination: destination-file-location

可以设置多个 sourcedestination 对。

source 指令标识要复制到实例的修订中的文件或目录:

  • 如果 source 是指一个文件,则仅指定的文件将复制到实例。

  • 如果 source 是指一个目录,则该目录中的所有文件都将复制到实例。

  • 如果 source 是一个单斜杠 (/),则修订中的所有文件都将复制到实例。

source 中使用的路径是相对路径(从修订的根目录开始)。

destination 指令标识应将文件复制到的实例上位置。此路径必须是完全限定的路径。

下面是 Amazon Linux、Ubuntu Server 或 RHEL 实例的示例 files 部分。

Copy
files: - source: Config/config.txt destination: /webapps/Config - source: source destination: /webapps/myApp

在此示例中,将在 Install 事件期间执行下面两种操作:

  1. 将修订中的 Config/config.txt 文件复制到实例上的 /webapps/Config/config.txt 路径中。

  2. 以递归方式将修订 source 目录中的所有文件复制到实例上的 /webapps/myApp 目录中。

“files”部分示例

以下示例显示如何指定 files 部分。尽管这些示例描述的是 Windows Server 文件和目录(文件夹)结构,但是它们可轻松适合于 Amazon Linux、Ubuntu Server 和 RHEL 实例。

对于以下示例,我们假设这些文件出现在 source 的根目录中:

  • appspec.yml

  • my-file.txt

  • my-file-2.txt

  • my-file-3.txt

Copy
# 1) Copy only my-file.txt to the destination folder c:\temp. # files: - source: .\my-file.txt destination: c:\temp # # Result: # c:\temp\my-file.txt # # --------------------- # # 2) Copy only my-file-2.txt and my-file-3.txt to the destination folder c:\temp. # files: - source: my-file-2.txt destination: c:\temp - source: my-file-3.txt destination: c:\temp # # Result: # c:\temp\my-file-2.txt # c:\temp\my-file-3.txt # # --------------------- # # 3) Copy my-file.txt, my-file-2.txt, and my-file-3.txt (along with the appspec.yml file) to the destination folder c:\temp. # files: - source: \ destination: c:\temp # # Result: # c:\temp\appspec.yml # c:\temp\my-file.txt # c:\temp\my-file-2.txt # c:\temp\my-file-3.txt

对于以下示例,我们假设 appspec.yml 与包含三个文件的 my-folder 文件夹一起出现在 source 的根目录中:

  • appspec.yml

  • my-folder\my-file.txt

  • my-folder\my-file-2.txt

  • my-folder\my-file-3.txt

Copy
# 4) Copy the 3 files in my-folder (but do not copy my-folder itself) to the destination folder c:\temp. # files: - source: .\my-folder destination: c:\temp # # Result: # c:\temp\my-file.txt # c:\temp\my-file-2.txt # c:\temp\my-file-3.txt # # --------------------- # # 5) Copy my-folder and its 3 files to my-folder within the destination folder c:\temp. # files: - source: .\my-folder destination: c:\temp\my-folder # # Result: # c:\temp\my-folder\my-file.txt # c:\temp\my-folder\my-file-2.txt # c:\temp\my-folder\my-file-3.txt # # --------------------- # # 6) Copy the 3 files in my-folder to other-folder within the destination folder c:\temp. # files: - source: .\my-folder destination: c:\temp\other-folder # # Result: # c:\temp\other-folder\my-file.txt # c:\temp\other-folder\my-file-2.txt # c:\temp\other-folder\my-file-3.txt # # --------------------- # # 7) Copy only my-file-2.txt and my-file-3.txt to my-folder within the destination folder c:\temp. # files: - source: .\my-folder\my-file-2.txt destination: c:\temp\my-folder - source: .\my-folder\my-file-3.txt destination: c:\temp\my-folder # # Result: # c:\temp\my-folder\my-file-2.txt # c:\temp\my-folder\my-file-3.txt # # --------------------- # # 8) Copy only my-file-2.txt and my-file-3.txt to other-folder within the destination folder c:\temp. # files: - source: .\my-folder\my-file-2.txt destination: c:\temp\other-folder - source: .\my-folder\my-file-3.txt destination: c:\temp\other-folder # # Result: # c:\temp\other-folder\my-file-2.txt # c:\temp\other-folder\my-file-3.txt # # --------------------- # # 9) Copy my-folder and its 3 files (along with the appspec.yml file) to the destination folder c:\temp. # files: - source: \ destination: c:\temp # # Result: # c:\temp\appspec.yml # c:\temp\my-folder\my-file.txt # c:\temp\my-folder\my-file-2.txt # c:\temp\my-folder\my-file-3.txt

本页内容: