Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support injectable buildspecs #2

Merged
merged 1 commit into from
Aug 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions cumulus/steps/development/code_build_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ def __init__(self,
input_artifact_name,
stage_name_to_add,
environment=None,
vpc_config=None):
vpc_config=None,
buildspec='buildspec.yml'):
"""
:type buildspec: basestring path to buildspec.yml or text containing the buildspec.
:type input_artifact_name: basestring The artifact name in the pipeline. Must contain a buildspec.yml
:type action_name: basestring Displayed on the console
:type environment: troposphere.codebuild.Environment Optional if you need ENV vars or a different build.
:type vpc_config.Vpc_Config: Only required if the codebuild step requires access to the VPC
"""
step.Step.__init__(self)
self.buildspec = buildspec
self.environment = environment
self.input_artifact_name = input_artifact_name
self.action_name = action_name
Expand Down Expand Up @@ -124,7 +127,7 @@ def create_project(self, chain_context, codebuild_role, codebuild_environment, n
# Configure vpc if available
if self.vpc_config:
sg = ec2.SecurityGroup(
"CodebBuild%sSG" % chain_context.instance_name,
"CodebBuild%s%sSG" % (self.stage_name_to_add ,self.action_name),
GroupDescription="Gives codebuild access to VPC",
VpcId=self.vpc_config.vpc_id,
SecurityGroupEgress=[
Expand All @@ -144,6 +147,7 @@ def create_project(self, chain_context, codebuild_role, codebuild_environment, n
)}

project_name = "project%s" % name

project = codebuild.Project(
project_name,
DependsOn=codebuild_role,
Expand All @@ -154,6 +158,7 @@ def create_project(self, chain_context, codebuild_role, codebuild_environment, n
Source=codebuild.Source(
"Deploy",
Type='CODEPIPELINE',
BuildSpec=self.buildspec,
),
**vpc_config
)
Expand Down
2 changes: 1 addition & 1 deletion cumulus/steps/development/pipeline_source_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self,
"""
:type s3_object_key: basestring Path of the artifact in the bucket.
:type s3_bucket_name: basestring or troposphere.Ref Object of the bucket name.
:type input_artifact_name: basestring The artifact name in the pipeline. Must contain a buildspec.yml
:type input_artifact_name: basestring The artifact name in the pipeline. (contains buildspec.yml. You can override that name in a codebuild action)
:type action_name: basestring Displayed on the console
:type environment: troposphere.codebuild.Environment Optional if you need ENV vars or a different build.
:type vpc_config.Vpc_Config: Only required if the codebuild step requires access to the VPC
Expand Down
5 changes: 5 additions & 0 deletions push_tags_and_master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

git push origin --tags
git push origin master

2 changes: 1 addition & 1 deletion tests/unit/steps/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_code_build_should_add_vpc_config(self):
'dummy-subnet1'
]
),
action_name="test-action",
action_name="testAction",
stage_name_to_add="thestage",
input_artifact_name="test-input"
)
Expand Down