代码管道限制代码构建中的工件属性
Codepipeline restricting artifact properties in codebuild
我已经创建了一个 codebuild 来根据 codecommit 中的更改来构建我的项目。这是它的 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
并将其以 zip 格式保存在指定的存储桶中。
但是当我将相同的代码构建与 Codepipeline 集成时,它会根据此 覆盖存储桶名称。即使我尝试使用 cloudformation 更改存储桶名称,但我如何从上面的代码片段中添加在工件部分(即 name
)中定义的参数,因为我会将此 name
指向 S3KeyName
在我的 cloudformation 模板中。
我试图更改我通过 运行 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
的文件夹,而不是创建文件。文件结构是这样的
---MultiBuild
|
|
-->Lambda
|
|
abcd.zip
-->SourceArti
|
|
efgh.zip
对不起!这是 CodePipeline 管理工件的方式的不幸结果。 CodePipeline outputArtifacts 字段中的 "name" 只是一个逻辑名称。 CodePipeline 的设计是为了让未来的阶段可以引用在过去的阶段中使用该名称创建的工件。这些工件存储在您在管道中指定的存储桶中,但我认为您真的不希望在部署配置中使用这些对象。
如果您正在构建要部署到 Lambda 函数的 ZIP 文件,您可以在管道中创建第二阶段,部署到您拥有的 Lambda 函数:https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html
如果您只需要将 ZIP 文件放在可预测的位置(例如,s3://testxxxthe-codebuild/Lambda.zip
)以用于您创建的某些其他流程,我们已经从多个客户那里听到了您的用例,并且正在考虑使这种体验更好的方法。同时,您可能会发现以下论坛 post 很有用:https://forums.aws.amazon.com/thread.jspa?threadID=228984
我已经创建了一个 codebuild 来根据 codecommit 中的更改来构建我的项目。这是它的 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
并将其以 zip 格式保存在指定的存储桶中。
但是当我将相同的代码构建与 Codepipeline 集成时,它会根据此 name
)中定义的参数,因为我会将此 name
指向 S3KeyName
在我的 cloudformation 模板中。
我试图更改我通过 运行 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
的文件夹,而不是创建文件。文件结构是这样的
---MultiBuild
|
|
-->Lambda
|
|
abcd.zip
-->SourceArti
|
|
efgh.zip
对不起!这是 CodePipeline 管理工件的方式的不幸结果。 CodePipeline outputArtifacts 字段中的 "name" 只是一个逻辑名称。 CodePipeline 的设计是为了让未来的阶段可以引用在过去的阶段中使用该名称创建的工件。这些工件存储在您在管道中指定的存储桶中,但我认为您真的不希望在部署配置中使用这些对象。
如果您正在构建要部署到 Lambda 函数的 ZIP 文件,您可以在管道中创建第二阶段,部署到您拥有的 Lambda 函数:https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html
如果您只需要将 ZIP 文件放在可预测的位置(例如,s3://testxxxthe-codebuild/Lambda.zip
)以用于您创建的某些其他流程,我们已经从多个客户那里听到了您的用例,并且正在考虑使这种体验更好的方法。同时,您可能会发现以下论坛 post 很有用:https://forums.aws.amazon.com/thread.jspa?threadID=228984