我正在设计一个 CI/CD 系统并寻求前端和后端组件之间的完全隔离。他们将使用单独的 CodeCommit 存储库、CodeBuild 项目和部署机制。我什至创建了单独的 S3 存储桶来存放工件。此外,我为管道和相关服务使用了冗长的描述性名称,以确保不会造成混淆。
但是,我遇到了一个恼人的问题,即 CodePipeline 似乎在我的工件 S3 存储桶中创建了一个文件夹,其中包含管道名称的截断版本。我觉得这是无关紧要的,只会增加我试图避免的困惑。整个 S3 存储桶专用于那些管道工件,因此我不想要一个包含其中所有内容的文件夹。无论如何,我看不到要阻止 CodePipeline 以这种方式运行。
例子:
Pipeline Name: my-clients-pipeline-for-frontend
S3 Artifacts: my-clients-pipeline-artifacts-for-frontend
----> my-clients-pipeline-f
--------> SourceArtifact
--------> BuildAritfact
Pipeline Name: my-clients-pipeline-for-backend
S3 Artifacts: my-clients-pipeline-artifacts-for-backend
----> my-clients-pipeline-f
--------> SourceArtifact
--------> BuildAritfact
文档指出,
"Every time you use the console to create another pipeline in that Region, CodePipeline creates a folder for that pipeline in the bucket. It uses that folder to store artifacts for your pipeline as the automated release process runs."
尽管如此,我正在使用 CloudFormation 构建管道,但不确定这是否仍然适用。管道正在运行...我能以某种方式删除这个被截断的文件夹吗?
https://docs.aws.amazon.com/codepipeline/latest/userguide/welcome-introducing-artifacts.html
最佳答案
此回复晚了 19 个月,所以我希望您能在此期间找到解决方案。 ^-^
我通常会在我的管道运行时尝试使用 aws CLI 来处理与 AWS Env 修改相关的任何事情。因此,例如在您的情况下,如果您手动将输出工件设置为使用适当名称的存储桶,即:“my-clients-pipeline-artifacts-for-backend”,那么您可以在部署阶段之后添加一个阶段来调用例如,使用 aws CLI 删除 AWS CodePipeline 创建的任何文件夹的 AWS Lambda:
aws s3 rm s3://my-clients-pipeline-for-backend/my-clients-pipeline-f
--recursive
此命令递归地删除文件夹中的所有内容:“my-clients-pipeline-f”,然后也删除文件夹本身。
我知道这不是一种非常简单的方法,但它是一种在大多数情况下都适合我的解决方法/解决方案。我没有测试这个删除构建工件 s3 文件夹,但它应该工作正常。
在 Lambda 中集成 AWS CLI:https://bezdelev.com/hacking/aws-cli-inside-lambda-layer-aws-s3-sync/
在 CodePipeline 中调用 Lambda:https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html#actions-invoke-lambda-function-add-action
关于amazon-web-services - 如何更改 CodePipeline 工件行为? (如果可能的话),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63803979/