Amazon web services 代码管道限制代码构建中的工件属性
我已经创建了一个codebuild来基于codecommit中的更改构建我的项目。这是它的批处理获取项目的Amazon web services 代码管道限制代码构建中的工件属性,amazon-web-services,aws-codepipeline,aws-codebuild,Amazon Web Services,Aws Codepipeline,Aws Codebuild,我已经创建了一个codebuild来基于codecommit中的更改构建我的项目。这是它的批处理获取项目的命令详细信息 { "projects": [ { "name": "MultiRepBuild", "arn": "arn:aws:codebuild:us-east-1:100000xxx0x:project/MultiRepBui ld", "source": {
命令详细信息
{
"projects": [
{
"name": "MultiRepBuild",
"arn": "arn:aws:codebuild:us-east-1:100000xxx0x:project/MultiRepBui
ld",
"source": {
"type": "CODECOMMIT",
"location": "https://git-codecommit.us-east-1.amazonaws.com/v1/r
epos/PythonRep",
"gitCloneDepth": 1,
"insecureSsl": false
},
"secondarySources": [],
"artifacts": {
"type": "S3",
"location": "testxxxthe-codebuild",
"path": "",
"namespaceType": "NONE",
"name": "Lambda",
"packaging": "ZIP",
"overrideArtifactName": false,
"encryptionDisabled": false
},
"secondaryArtifacts": [],
"cache": {
"type": "NO_CACHE"
},
"environment": {
"type": "LINUX_CONTAINER",
"image": "aws/codebuild/python:3.6.5",
"computeType": "BUILD_GENERAL1_SMALL",
"environmentVariables": [],
"privilegedMode": false
},
"serviceRole": "arn:aws:iam::xxxxxxxx:role/service-role/codebuil
d-MultiRepBuild-service-role",
"timeoutInMinutes": 60,
"encryptionKey": "arn:aws:kms:us-east-1:xxxxxx:alias/aws/s3",
"tags": [],
"created": 1542607679.567,
"lastModified": 1542611632.345,
"badge": {
"badgeEnabled": false
}
}
],
"projectsNotFound": []
}
此代码构建将创建具有指定名称Lambda
的buildartifact,并以zip格式将其保存在指定的bucket中
但当我将相同的代码构建与代码管道集成时,它将覆盖bucketname,如下所示。即使我尝试使用cloudformation更改bucketname,但我如何从上面的代码片段中添加工件部分中定义的参数(即name
),因为我将在cloudformation模板中将此name
作为S3KeyName
我试图通过运行aws codepippeline get pipeline--name MyFirstPipeline>pipeline.json
命令来更改下面文件中的名称
{
"pipeline": {
"name": "MultiBuild",
"roleArn": "arn:aws:iam::xxxxxxxxxxx:role/service-role/AWSCodePipelineServiceRole-us-east-1-MultiBuild",
"artifactStore": {
"type": "S3",
"location": "codepipeline-us-east-1-xxxxx"
},
"stages": [
{
"name": "Source",
"actions": [
{
"name": "Source",
"actionTypeId": {
"category": "Source",
"owner": "AWS",
"provider": "CodeCommit",
"version": "1"
},
"runOrder": 1,
"configuration": {
"BranchName": "master",
"PollForSourceChanges": "false",
"RepositoryName": "PythonRep"
},
"outputArtifacts": [
{
"name": "SourceArtifact"
}
],
"inputArtifacts": []
}
]
},
{
"name": "Build",
"actions": [
{
"name": "Build",
"actionTypeId": {
"category": "Build",
"owner": "AWS",
"provider": "CodeBuild",
"version": "1"
},
"runOrder": 1,
"configuration": {
"ProjectName": "MultiRepBuild"
},
"outputArtifacts": [
{
"name": "Lambda" -->Here
}
],
"inputArtifacts": [
{
"name": "SourceArtifact"
}
]
}
]
}
],
"version": 1
}
}
这是创建名为Lambda
的文件夹,而不是创建文件。文件结构如下所示
---MultiBuild
|
|
-->Lambda
|
|
abcd.zip
-->SourceArti
|
|
efgh.zip
对不起!这是CodePipeline管理工件方式的一个不幸结果。CodePipeline outputArtifacts字段中的“名称”只是一个逻辑名称。CodePipeline的设计使得未来的阶段可以引用在过去阶段中创建的具有该名称的工件。这些工件存储在您在管道中指定的bucket中,但我不认为您真的希望在部署配置中使用这些对象
如果要构建要部署到Lambda函数的ZIP文件,可以在管道中创建第二个阶段,该阶段将部署到现有的Lambda函数:
如果您只需要将ZIP文件放在您创建的其他流程的可预测位置(例如,s3://testxxxthe codebuild/Lambda.ZIP
),我们已经从多个客户那里听到了您的使用案例,并且正在考虑如何使这种体验更好。同时,你可能会发现以下论坛帖子很有用:谢谢@Matthew。实际上,我通过使用build命令(即zip foldername
)压缩lambda文件夹中的所有lambda内容,并使用aws s3 cp.解决了这个问题
命令将压缩文件夹保存在S3
bucket中。