codebuild 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/docs/_docs/examples/ecs.md +2 -0
- data/docs/_docs/examples/jets.md +17 -6
- data/docs/_docs/examples/ruby.md +6 -6
- data/docs/_includes/commands.html +1 -2
- data/docs/_includes/examples-steps.md +17 -0
- data/lib/codebuild/deploy.rb +28 -0
- data/lib/codebuild/init.rb +1 -1
- data/lib/codebuild/stack.rb +1 -10
- data/lib/codebuild/version.rb +1 -1
- metadata +3 -3
- data/docs/favicon.ico +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a61acb91b1f2eb181094bd20117879da0219931178fec03054f930f06cf3fd4a
|
4
|
+
data.tar.gz: 9c462974ca5f372d437f490a44a88763373f852aca75c727bfcf58e9f853f599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30a6738433fb64cd50b2237f6f7a8d78c3dcd9bc281b836eed6f869bb295d462f0778499e17c79adb06031af8908d2c89581fef74d49cb59d08026e50b18adc4
|
7
|
+
data.tar.gz: dd6342bfdfb19de9a91c16736b3a2edf939b7bd05e72675797f22777d0c6c44171cf960c225b4f0c97ac35294f177291c9a1b45fb872f70a08ce68c940fe0bc7
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.6.1]
|
7
|
+
- cb init: no variables by default
|
8
|
+
- fix handle rollback
|
9
|
+
|
6
10
|
## [0.6.0]
|
7
11
|
- named stack with -cb at the very end
|
8
12
|
- add docs
|
data/docs/_docs/examples/ecs.md
CHANGED
@@ -85,6 +85,8 @@ managed_iam_policy("AmazonS3ReadOnlyAccess") # optional but common to need read
|
|
85
85
|
|
86
86
|
From a security perspective, using CodeBuild gives us a stronger security posture. The **only** permission the user calling [cb start]({% link _docs/start.md %}) really needs is CodeBuild access. The permissions to create the ECS service and other deployment resources are delegated to the CodeBuild project itself. We know that the CodeBuild project will not run any arbitrary commands unless we update `buildspec.yml` and explicitly give permission to it's IAM role.
|
87
87
|
|
88
|
+
{% include examples-steps.md %}
|
89
|
+
|
88
90
|
## CodePipeline ECS Deploy Action
|
89
91
|
|
90
92
|
If you are using CodePipeline also, you may be wondering why not just use the provided Amazon ECS deployment action instead. It comes down to control. With a CodeBuild project, we have full control of how we want to build and deploy the Docker image to ECS.
|
data/docs/_docs/examples/jets.md
CHANGED
@@ -13,13 +13,15 @@ Here's the project DSL.
|
|
13
13
|
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
github_url("https://github.com/tongueroo/jets-
|
17
|
-
linux_image("
|
16
|
+
github_url("https://github.com/tongueroo/jets-codebuild")
|
17
|
+
linux_image("timbru31/ruby-node:2.5") # currently must used ruby 2.5 for Lambda
|
18
18
|
environment_variables(
|
19
19
|
JETS_ENV: Codebuild.env,
|
20
20
|
)
|
21
21
|
```
|
22
22
|
|
23
|
+
The [.codebuild/project.rb](.codebuild/project.rb) uses a Docker image that has ruby, node, and yarn already installed. If you prefer to use another image, update the `linux_image` setting, and update your `buildspec.yml` accordingly. IE: Install the necessary packages.
|
24
|
+
|
23
25
|
Here's the buildspec:
|
24
26
|
|
25
27
|
.codebuild/buildspec.yml
|
@@ -30,20 +32,20 @@ version: 0.2
|
|
30
32
|
phases:
|
31
33
|
install:
|
32
34
|
commands:
|
33
|
-
- apt-get update -y
|
35
|
+
- apt-get update -y
|
36
|
+
- apt-get install -y rsync zip
|
34
37
|
build:
|
35
38
|
commands:
|
36
39
|
- echo Build started on `date`
|
37
40
|
- sed -i '/BUNDLED WITH/Q' Gemfile.lock # hack to fix bundler issue: allow different versions of bundler to work
|
38
|
-
- gem install bundler:1.16.6
|
39
|
-
- export JETS_ENV=test
|
40
41
|
- bundle
|
41
|
-
- bundle exec rspec
|
42
|
+
- JETS_ENV=test bundle exec rspec
|
42
43
|
post_build:
|
43
44
|
commands:
|
44
45
|
- bash -c 'if [ "$CODEBUILD_BUILD_SUCCEEDING" == "0" ]; then exit 1; fi'
|
45
46
|
- export JETS_AGREE=yes
|
46
47
|
- bundle exec jets deploy $JETS_ENV
|
48
|
+
|
47
49
|
```
|
48
50
|
|
49
51
|
And here are the IAM permissions required as described in [Jets Minimal IAM Deploy Policy](https://rubyonjets.com/docs/extras/minimal-deploy-iam/).
|
@@ -65,4 +67,13 @@ iam_policy(
|
|
65
67
|
)
|
66
68
|
```
|
67
69
|
|
70
|
+
Here's also Github repo with CodeBuild examples with Jets: [tongueroo/jets-codebuild](https://github.com/tongueroo/jets-codebuild). The example on the master branch is a similar simple approach with 1 CodeBuild project.
|
71
|
+
|
72
|
+
You may be interested in the [separate-unit-and-deploy branch](https://github.com/tongueroo/jets-codebuild/tree/separate-unit-and-deploy). The example shows how to set up 2 separate CodeBuild projects. Some advantages:
|
73
|
+
|
74
|
+
* The projects are decoupled and you can run them separately.
|
75
|
+
* Only the deploy project requires IAM access to create the AWS resources.
|
76
|
+
|
77
|
+
{% include examples-steps.md %}
|
78
|
+
|
68
79
|
{% include prev_next.md %}
|
data/docs/_docs/examples/ruby.md
CHANGED
@@ -5,7 +5,7 @@ categories: example
|
|
5
5
|
nav_order: 18
|
6
6
|
---
|
7
7
|
|
8
|
-
This examples show to run
|
8
|
+
This examples show to run Ruby unit tests.
|
9
9
|
|
10
10
|
Here's the project DSL.
|
11
11
|
|
@@ -30,15 +30,15 @@ version: 0.2
|
|
30
30
|
phases:
|
31
31
|
install:
|
32
32
|
commands:
|
33
|
-
- apt-get update -y
|
33
|
+
- apt-get update -y apt-get install -y rsync
|
34
34
|
build:
|
35
35
|
commands:
|
36
36
|
- echo Build started on `date`
|
37
37
|
- sed -i '/BUNDLED WITH/Q' Gemfile.lock # hack to fix bundler issue: allow different versions of bundler to work
|
38
|
-
- gem install bundler:1.16.6
|
39
|
-
- export JETS_ENV=test
|
40
38
|
- bundle
|
41
|
-
- bundle exec rspec
|
39
|
+
- JETS_ENV=test bundle exec rspec
|
42
40
|
```
|
43
41
|
|
44
|
-
{% include
|
42
|
+
{% include examples-steps.md %}
|
43
|
+
|
44
|
+
{% include prev_next.md %}
|
@@ -39,10 +39,9 @@ cb delete
|
|
39
39
|
<div class="commands">
|
40
40
|
{% highlight sh %}
|
41
41
|
cb deploy # infers the CloudFormation name from the parent folder
|
42
|
-
cb deploy
|
42
|
+
cb deploy project-name # explicitly specify project name
|
43
43
|
|
44
44
|
cb start # infers the name from the parent folder
|
45
|
-
cb start stack-name # looks up project via CloudFormation stack
|
46
45
|
cb start demo-project # looks up project via CodeBuild project name
|
47
46
|
{% endhighlight %}
|
48
47
|
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
## Create CodeBuild Project
|
2
|
+
|
3
|
+
To create the CodeBuild project via CloudFormation run:
|
4
|
+
|
5
|
+
cb deploy demo
|
6
|
+
|
7
|
+
This creates the CodeBuild project as well as the necessary IAM role.
|
8
|
+
|
9
|
+
## Start Build
|
10
|
+
|
11
|
+
To start a build:
|
12
|
+
|
13
|
+
cb start
|
14
|
+
|
15
|
+
You can also start a build with a specific branch. Remember to `git push` your branch.
|
16
|
+
|
17
|
+
cb start -b mybranch
|
data/lib/codebuild/deploy.rb
CHANGED
@@ -1,11 +1,39 @@
|
|
1
1
|
module Codebuild
|
2
2
|
class Deploy < Stack
|
3
3
|
def run
|
4
|
+
handle_rollback_completed!
|
4
5
|
if stack_exists?(@stack_name)
|
5
6
|
Update.new(@options).run
|
6
7
|
else
|
7
8
|
Create.new(@options).run
|
8
9
|
end
|
9
10
|
end
|
11
|
+
|
12
|
+
def handle_rollback_completed!
|
13
|
+
@stack = find_stack(@stack_name)
|
14
|
+
if @stack && rollback_complete?(@stack)
|
15
|
+
puts "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
|
16
|
+
cfn.delete_stack(stack_name: @stack_name)
|
17
|
+
status.wait
|
18
|
+
status.reset
|
19
|
+
@stack = nil # at this point stack has been deleted
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def rollback_complete?(stack)
|
24
|
+
stack.stack_status == 'ROLLBACK_COMPLETE'
|
25
|
+
end
|
26
|
+
|
27
|
+
def find_stack(stack_name)
|
28
|
+
resp = cfn.describe_stacks(stack_name: stack_name)
|
29
|
+
resp.stacks.first
|
30
|
+
rescue Aws::CloudFormation::Errors::ValidationError => e
|
31
|
+
# example: Stack with id demo-web does not exist
|
32
|
+
if e.message =~ /Stack with/ && e.message =~ /does not exist/
|
33
|
+
nil
|
34
|
+
else
|
35
|
+
raise
|
36
|
+
end
|
37
|
+
end
|
10
38
|
end
|
11
39
|
end
|
data/lib/codebuild/init.rb
CHANGED
@@ -8,7 +8,7 @@ module Codebuild
|
|
8
8
|
[:template, desc: "Custom template to use"],
|
9
9
|
[:template_mode, desc: "Template mode: replace or additive"],
|
10
10
|
[:type, desc: "Type option creates a subfolder under .codebuild"],
|
11
|
-
[:variables, type: :boolean, default:
|
11
|
+
[:variables, type: :boolean, default: false, desc: "Create variables starter files"],
|
12
12
|
]
|
13
13
|
end
|
14
14
|
cli_options.each { |o| class_option(*o) }
|
data/lib/codebuild/stack.rb
CHANGED
@@ -45,15 +45,6 @@ module Codebuild
|
|
45
45
|
return if @options[:noop]
|
46
46
|
puts "Deploying stack #{@stack_name.color(:green)} with CodeBuild project #{@full_project_name.color(:green)}"
|
47
47
|
|
48
|
-
@stack = find_stack(@stack_name)
|
49
|
-
if @stack && rollback_complete?(@stack)
|
50
|
-
puts "Existing stack in ROLLBACK_COMPLETE state. Deleting stack before continuing."
|
51
|
-
cfn.delete_stack(stack_name: @stack_name)
|
52
|
-
status.wait
|
53
|
-
status.reset
|
54
|
-
@stack = nil # at this point stack has been deleted
|
55
|
-
end
|
56
|
-
|
57
48
|
begin
|
58
49
|
perform
|
59
50
|
url_info
|
@@ -64,7 +55,7 @@ module Codebuild
|
|
64
55
|
if e.message.include?("No updates") # No updates are to be performed.
|
65
56
|
puts "WARN: #{e.message}".color(:yellow)
|
66
57
|
else
|
67
|
-
puts "ERROR: #{e.message}".color(:red)
|
58
|
+
puts "ERROR ValidationError: #{e.message}".color(:red)
|
68
59
|
exit 1
|
69
60
|
end
|
70
61
|
end
|
data/lib/codebuild/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: codebuild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- docs/_includes/commands.html
|
257
257
|
- docs/_includes/content.html
|
258
258
|
- docs/_includes/edit-on-github.html
|
259
|
+
- docs/_includes/examples-steps.md
|
259
260
|
- docs/_includes/footer.html
|
260
261
|
- docs/_includes/google_analytics.html
|
261
262
|
- docs/_includes/head.html
|
@@ -290,7 +291,6 @@ files:
|
|
290
291
|
- docs/_sass/_variables.scss
|
291
292
|
- docs/bin/web
|
292
293
|
- docs/docs.md
|
293
|
-
- docs/favicon.ico
|
294
294
|
- docs/img/docs/codebuild-output.png
|
295
295
|
- docs/img/logos/boltops-logo-full.png
|
296
296
|
- docs/img/logos/boltops-logo.png
|
data/docs/favicon.ico
DELETED
Binary file
|