我已经创建了一个代码构建以根据代码提交中的更改来构建我的项目。这是batch-get-projects
命令的详细信息
{
"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格式保存在指定的存储区中。
但是,当我将相同的代码构建与Codepipeline集成时,它将按照此answer覆盖存储桶名称。即使我尝试使用cloudformation更改存储桶名称,但如何从上述代码段中添加工件部分(即name
)中定义的参数,因为我会将这个name
指向一个{{ 1}}在我的cloudformation模板中。
我试图通过运行S3KeyName
命令更改下面文件的名称
aws codepipeline 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
答案 0 :(得分:1)
对不起!这是CodePipeline管理工件的方式的不幸结果。 CodePipeline outputArtifacts字段中的“名称”只是一个逻辑名称。设计CodePipeline是为了使以后的阶段可以引用在过去阶段使用该名称创建的工件。这些工件存储在您在管道中指定的存储桶中,但是我认为确实不希望您在部署配置中使用这些对象。
如果您要构建要部署到Lambda函数的ZIP文件,则可以在管道中创建第二阶段,以将其部署到您拥有的Lambda函数:https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html
如果您只是需要将ZIP文件放在可预见的位置(例如s3://testxxxthe-codebuild/Lambda.zip
),以进行您创建的其他一些流程,我们已经从多个客户那里听到了您的用例,并正在考虑以下方法使这种体验更好。同时,您可能会发现以下论坛帖子有用:https://forums.aws.amazon.com/thread.jspa?threadID=228984