codepipeline 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c512eabee2e9506733bde41ee89c2b83f03c5a45ea4e5abb31a96cee369cbe89
4
- data.tar.gz: 1920d0720610d8388ac4502a24a794ead85eec0ecbde04100f9e9bc7265c99e1
3
+ metadata.gz: d01768e8b5b7fd0c0df102e9722aa1142465dc4cb558b1ba8b89729f22d5b190
4
+ data.tar.gz: de37faf1c520534e98c098985b9c8aea780c19c31caa969b80c9b1da2861dc13
5
5
  SHA512:
6
- metadata.gz: 626e1e6bede33a5b1fec8b774b015334b9f8d996f335f778f92eef8a538395266c4a205eedd033ccd0cefcb15b59f3a30ecd2c8b7d5ee4cd43c3397d295d77e2
7
- data.tar.gz: f6f14e543a7275a3deb546031bd65444d1f3191fae20f3c1e395ef3aadfd6005406d5840dfb26214ad8bca5b20dcab34d0fe679add107fabab72be09c3229601
6
+ metadata.gz: 7bb42521c93b928e9454c2cf9d261bf2a3c0de7c2bbcd4c5514a91be7175f26051a3fdde0c3f8c120c3d92dc1d4aa8d3ff28f11da080b944214b6fa8e8222a68
7
+ data.tar.gz: 10ae3dd56585edc11cd76adbaef808afdcdfdf28eb9a2935a1fa1e158b9a187bb238b8a6c058984ce91bf9cd25dc830617353fba99fcee20f800e42d6e65952c
@@ -0,0 +1,9 @@
1
+ version: 0.2
2
+
3
+ phases:
4
+ build:
5
+ commands:
6
+ - echo Build started on `date`
7
+ - sed -i '/BUNDLED WITH/Q' Gemfile.lock # hack to fix bundler issue: allow different versions of bundler to work
8
+ - bundle
9
+ - bundle exec rspec
@@ -0,0 +1,4 @@
1
+ github_url("https://github.com/tongueroo/codepipeline")
2
+ linux_image("aws/codebuild/ruby:2.5.3-1.7.0")
3
+ triggers(webhook: true)
4
+ local_cache(false)
@@ -0,0 +1,9 @@
1
+ base:
2
+ # stack_naming:
3
+ # append_env: true # default false
4
+
5
+ development:
6
+ # aws_profile: dev_profile
7
+
8
+ production:
9
+ # aws_profile: prod_profile
data/CHANGELOG.md CHANGED
@@ -3,6 +3,9 @@
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.3.0]
7
+ - update docs and cli help
8
+
6
9
  ## [0.2.1]
7
10
  - fix different branch check
8
11
 
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Codepipeline
2
2
 
3
+ ![Build Status](https://codebuild.us-west-2.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiM3hGMlViMUtRRS9maitXVnhPNUp2ZFE3eUkzV0doNG5OR0lRRGtNOVBiWDVsb0tjY2dTVnhHamJOSzZRYU5aaW9FOS9peEUwVHBVUzk3cXVjd2FqcHFNPSIsIml2UGFyYW1ldGVyU3BlYyI6InNDdzUzVmRCd0FHSjBrTnQiLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master)
3
4
  [![Gem Version](https://badge.fury.io/rb/codepipeline.png)](http://badge.fury.io/rb/codepipeline)
4
5
 
5
6
  The codepipeline tool provides a DSL to create a CodePipeline project with some reasonable defaults.
@@ -26,9 +27,8 @@ The CLI tool also detects and tasks in the current folder's Rakefile and delegat
26
27
  ```ruby
27
28
  stage "Source" do
28
29
  github(
29
- source: "tongueroo/demo-cb",
30
- branch: "master",
31
- auth_token: ssm("/codebuild/github/tongueroo/oauth_token")
30
+ source: "tongueroo/demo-ufo",
31
+ auth_token: ssm("/github/user/token")
32
32
  )
33
33
  end
34
34
  stage "DeployStacks" do
@@ -38,7 +38,7 @@ stage "DeployStacks" do
38
38
  end
39
39
  ```
40
40
 
41
- More [DSL docs](docs/dsl)
41
+ More [DSL docs](https://codepipeline.org/docs/dsl/)
42
42
 
43
43
  ## Installation
44
44
 
@@ -14,7 +14,7 @@ It will set the pipeline name by inferring the name of the parent folder. For e
14
14
 
15
15
  The pipeline is named `demo`. You can override this easily by providing a pipeline name.
16
16
 
17
- cd deploy my-pipeline # explicitly use my-pipeline as pipeline name
17
+ pipe deploy my-pipeline # explicitly use my-pipeline as pipeline name
18
18
 
19
19
  The pipeline is named `my-pipeline`
20
20
 
@@ -28,16 +28,15 @@ The pipeline is named `my-pipeline-2`.
28
28
 
29
29
  ## Settings append_env option
30
30
 
31
- If the append_env is configured in the [Settings]({% link _docs/settings.md %}).
31
+ If the append_env is configured in the [Settings]({% link _docs/settings.md %}), then the `PIPE_ENV` is added to the pipeline name. For example: `demo-development` instead of `demo`.
32
32
 
33
33
  ## Stack Name
34
34
 
35
- The CloudFormation stack name which creates the CodePipeline related resources is named the same as the pipeline name with `-cb` appended to the stack name. Examples:
35
+ The CloudFormation stack name which creates the CodePipeline related resources is named the same as the pipeline name with `-pipe` appended to the stack name. Examples:
36
36
 
37
37
  Pipeline Name | Stack Name
38
38
  --- | ---
39
- demo | demo-cb
40
- demo-unit | demo-unit-cb
41
- demo-web-unit | demo-web-unit-cb
39
+ demo | demo-pipe
40
+ my-app | my-app-pipe
42
41
 
43
42
  {% include prev_next.md %}
data/docs/_docs/deploy.md CHANGED
@@ -3,7 +3,7 @@ title: Deploy
3
3
  nav_order: 4
4
4
  ---
5
5
 
6
- The pipeline is generated from the DSL and created with CloudFormation. By default, the files that the DSL evaluates are:
6
+ The pipeline is generated from the DSL and created with CloudFormation. The files that the DSL evaluates are in the `.codepipeline` folder:
7
7
 
8
8
  .codepipeline/pipeline.rb
9
9
  .codepipeline/role.rb
@@ -12,7 +12,7 @@ The pipeline is generated from the DSL and created with CloudFormation. By defau
12
12
 
13
13
  To create the CodePipeline pipeline, you run:
14
14
 
15
- codepipeline deploy
15
+ pipe deploy
16
16
 
17
17
  You'll see output that looks something like this:
18
18
 
@@ -46,23 +46,11 @@ By default, the pipeline name is inferred and is the parent folder that you are
46
46
 
47
47
  ## Specify Git Branch
48
48
 
49
- It is useful to build pipelines with different source git branches. You can pass a `--branch` option to the `pipe deploy` command. In the `.codepipeline/pipeline.rb` use the DSL method `branch` to reference it. Example:
49
+ It is useful to build pipelines with different source git branches. You can pass a `--branch` option to the `pipe deploy` command. The cli `—-branch` option always takes the highest precedence. Example:
50
50
 
51
51
  pipe deploy my-pipeline --branch my-branch
52
52
 
53
- .codepipeline/pipeline.rb
54
-
55
- ```ruby
56
- stage "Source" do
57
- github(
58
- source: "tongueroo/demo-test",
59
- auth_token: ssm("/github/user/token")
60
- )
61
- end
62
- ```
63
-
64
- Note: Currently CodePipeline does not support specifying a source git branch at runtime. We can only specific it as part of the pipeline definition.
65
-
53
+ Note: When you specify a branch the codepipeline tool actually first updates the pipeline before starting the pipeline execution. This is done because CodePipeline does not natively support specifying the branch. It is discussed more here: [Using Different Branches]({% link _docs/examples/different-branches.md %}).
66
54
 
67
55
  ## CLI Reference
68
56
 
@@ -17,11 +17,11 @@ stage "Approve" do
17
17
  end
18
18
  ```
19
19
 
20
- In this case, the codepipeline tool creates and manages the SNS topic for you.
20
+ With CodePipeline, an SNS topic is required to be associated with the Approval Action. In the case of a String form, the codepipeline tool will automatically create and manage the SNS topic associated with the `approve` declaration.
21
21
 
22
22
  ## Simplified Configuration Hash
23
23
 
24
- If the approve method provided a Hash with the `notification_arn` and `custom_data` then the codepipeline tool will set the `configuration` directly. Example:
24
+ If the `approve` method is provided a Hash with the `notification_arn` and `custom_data`, then the codepipeline tool will set the `configuration` directly. Example:
25
25
 
26
26
  ```ruby
27
27
  stage "Approve" do
@@ -32,7 +32,7 @@ stage "Approve" do
32
32
  end
33
33
  ```
34
34
 
35
- In this case, the codepipeline will *not* create an SNS Topic as we're using an existing SNS topic.
35
+ In this case, the codepipeline will *not* create an SNS Topic as we're have specified an existing SNS topic.
36
36
 
37
37
  ## Full Config
38
38
 
@@ -5,7 +5,7 @@ categories: dsl-pipeline
5
5
  nav_order: 11
6
6
  ---
7
7
 
8
- The `action` method is a general way to add Actions to your pipeline Stages. Generally, it is recommended to use the helper methods like [codebuild]({% link _docs/dsl/pipeline/codebuild.md %}) and [approve]({% link _docs/dsl/approve.md %}) when possible as it makes the code concise. Here's an example of a pipeline using the general `action` method.
8
+ The `action` method is a general way to add Actions to pipeline Stages. Generally, it is recommended to use the helper methods like [codebuild]({% link _docs/dsl/pipeline/codebuild.md %}) and [approve]({% link _docs/dsl/approve.md %}) when possible as it makes the code concise. Here's an example of a pipeline using the general `action` method.
9
9
 
10
10
  ```ruby
11
11
  stage "Build" do
@@ -26,7 +26,7 @@ stage "Deploy" do
26
26
  end
27
27
  ```
28
28
 
29
- The Action names in the Stage would be a little lengthy and look like this: DemoWebDeploy, DemoClockDeploy, DemoWorkerDeploy. If you wanted to use shorter names, you'd need to use the [Simpified Hash Form]({% link _docs/dsl/pipeline/codebuild.md %}).
29
+ The resulting Action names in the Stage would be a little lengthy and look like this: `DemoWebDeploy`, `DemoClockDeploy`, `DemoWorkerDeploy`. If you wanted to use shorter names like `Web`, `Clock`, and `Worker`, you'd need to use the [Simpified Hash Form]({% link _docs/dsl/pipeline/codebuild.md %}).
30
30
 
31
31
  ```ruby
32
32
  # Example 2
@@ -7,7 +7,7 @@ nav_order: 10
7
7
 
8
8
  The pipeline DSL allows you to define the stages and actions within that stage with only a few lines of code. In the Quick Start, we define a very short pipeline for as a simple example. Here we'll show more of the DSL power.
9
9
 
10
- ```
10
+ ```ruby
11
11
  stage "Source" do
12
12
  github(
13
13
  source: "tongueroo/demo-test",
@@ -21,7 +21,7 @@ stage "Build" do
21
21
  end
22
22
 
23
23
  stage "Approve" do
24
- approve
24
+ approve("Approve this deploy")
25
25
  end
26
26
 
27
27
  stage "Deploy" do
@@ -13,10 +13,10 @@ For most cases, the default SNS topic should suffice. However, if you wish to co
13
13
  ```ruby
14
14
  display_name "my display_name"
15
15
  kms_master_key_id "String"
16
- # subscription([{
17
- # endpoint: '',
18
- # protocol: ','
19
- # }])
16
+ subscription([{
17
+ endpoint: 'my@email.com',
18
+ protocol: 'email', # protocol values: https://docs.aws.amazon.com/sns/latest/api/API_Subscribe.html
19
+ }])
20
20
  topic_name "string", # Recommend not setting because update requires: Replacement. Allow CloudFormation to set it so 2 pipelines dont have same SNS Topic name that collides
21
21
  ```
22
22
 
data/docs/_docs/dsl.md CHANGED
@@ -3,11 +3,37 @@ title: CodePipeline DSL
3
3
  nav_order: 8
4
4
  ---
5
5
 
6
- CodePipeline provides a simple yet powerful DSL to create CodePipeline related resources. Here are some examples of resources it can create:
6
+ CodePipeline provides a simple yet powerful DSL to create CodePipeline related resources. Here's an example:
7
+
8
+ ```ruby
9
+ stage "Source" do
10
+ github(
11
+ source: "tongueroo/demo-test",
12
+ auth_token: ssm("/github/user/token")
13
+ )
14
+ end
15
+
16
+ stage "Build" do
17
+ codebuild "demo1", "demo2"
18
+ codebuild "demo3"
19
+ end
20
+
21
+ stage "Approve" do
22
+ approve("Approve this deploy")
23
+ end
24
+
25
+ stage "Deploy" do
26
+ codebuild "deploy"
27
+ end
28
+ ```
29
+
30
+ Here are some examples of resources it can create:
7
31
 
8
32
  * [pipeline]({% link _docs/dsl/pipeline.md %}): The CodePipeline pipeline. This is required.
9
33
  * [iam role]({% link _docs/dsl/role.md %}): The IAM role associated with the CodePipeline pipeline.
10
34
  * [webhook]({% link _docs/dsl/webhook.md %}): The webhook associated with the CodePipeline pipeline.
11
- * [schedule]({% link _docs/dsl/schedule.md %}): An CloudWatch Event rule. The rule triggers the pipeline to start on a scheduled basis.
35
+ * [schedule]({% link _docs/dsl/schedule.md %}): An CloudWatch Event rule: triggers the pipeline to start on a scheduled basis.
36
+ * [approve]({% link _docs/dsl/approve.md %}): An manual approval action step.
37
+ * [sns topic]({% link _docs/dsl/sns.md %}): The SNS Topic associated with the approval step. This is optional and provides a way to customize the SNS topic if needed.
12
38
 
13
39
  {% include prev_next.md %}
@@ -1,11 +1,9 @@
1
1
  ---
2
2
  title: 'ECS Deploy: Codebuild ufo ship vs CodePipeline ECS Deploy'
3
- nav_order: 20
3
+ nav_order: 21
4
4
  ---
5
5
 
6
- CodePipeline comes with many [Action Type Integrations](https://docs.aws.amazon.com/codepipeline/latest/userguide/integrations-action-type.html). One of the Integrations is [Amazon Elastic Container Service](https://docs.aws.amazon.com/codepipeline/latest/userguide/integrations-action-type.html#integrations-deploy) deployment.
7
-
8
- Currently, it is recommended to use [codebuild and ufo](https://codebuild.cloud/docs/examples/ecs/) to handle deployment to ECS though. We discuss the main reasons below.
6
+ CodePipeline comes with many [Action Type Integrations](https://docs.aws.amazon.com/codepipeline/latest/userguide/integrations-action-type.html). One of the Integrations is [Amazon Elastic Container Service](https://docs.aws.amazon.com/codepipeline/latest/userguide/integrations-action-type.html#integrations-deploy) deployment. It is recommended to use [codebuild and ufo](https://codebuild.cloud/docs/examples/ecs/) to handle deployment to ECS though. We discuss some reasons below.
9
7
 
10
8
  ## Timeout
11
9
 
@@ -19,6 +17,6 @@ By using a codebuild project, we have control over the timeout.
19
17
 
20
18
  The way the current CodePipeline ECS Deploy Action works is that it pulls down the current ECS task definition that ECS service is using. It then replaces the image property on it. Last, it then updates the ECS service with the newly built Docker image.
21
19
 
22
- The [ufo tool] is more powerful. The `ufo ship` command also handles creating the [ELB Load Balancer]((https://ufoships.com/docs/extras/load-balancer/)) and a vanity [Route53 endpoint](https://ufoships.com/docs/extras/route53-support/) for us. Also, it keeps task definition codified.
20
+ The [ufo tool](https://ufoships.com) is more powerful. The `ufo ship` command also handles creating the [ELB Load Balancer]((https://ufoships.com/docs/extras/load-balancer/)) and a vanity [Route53 endpoint](https://ufoships.com/docs/extras/route53-support/) for us. Also, it keeps task definitions codified.
23
21
 
24
22
  {% include prev_next.md %}
@@ -0,0 +1,21 @@
1
+ ---
2
+ title: Create CodeBuild Project
3
+ nav_text: Create CodeBuild
4
+ categories: examples
5
+ nav_order: 18
6
+ ---
7
+
8
+ It is common to use codebuild as a Stage Action in the pipeline. Here's are instructions to quickly create a codebuild project.
9
+
10
+ We'll use the [codebuild.cloud](https://codebuild.cloud) tool to help with this. Here are the commands.
11
+
12
+ cb init # generates starter .codebuild files including the buildspec.yml
13
+ # commit and yours the .codebuild files
14
+ git add .codebuild
15
+ git commit -m 'add .codebuild files'
16
+ git push
17
+ pipe deploy demo # creates a codebuild project
18
+
19
+ There's also an example where we quickly create 4 test codebuild projects here: [Multiple CodeBuild Projects](https://codepipeline.org/docs/examples/multiple-codebuild-projects/).
20
+
21
+ {% include prev_next.md %}
@@ -2,7 +2,7 @@
2
2
  title: Using Different Branches
3
3
  nav_text: Different Branches
4
4
  categories: examples
5
- nav_order: 18
5
+ nav_order: 19
6
6
  ---
7
7
 
8
8
  CodePipeline currently does not supports starting the pipeline execution with different branches natively. To get around this, we can:
@@ -28,7 +28,7 @@ You might normally set the branch option in your pipeline.rb. Example:
28
28
  ```ruby
29
29
  stage "Source" do
30
30
  github(
31
- source: "tongueroo/demo-cb",
31
+ source: "user/repo",
32
32
  auth_token: ssm("/github/user/token")
33
33
  )
34
34
  end
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  title: Multiple CodeBuild Projects
3
- nav_text: CodeBuild Projects
3
+ nav_text: Multiple CodeBuild
4
4
  categories: examples
5
- nav_order: 19
5
+ nav_order: 20
6
6
  ---
7
7
 
8
8
  In this example guide, we'll create a couple of test CodeBuild projects and quickly connect them up to a pipeline.
@@ -22,11 +22,11 @@ First, you can use `cb init` create some starter ``.codebuild` files.
22
22
 
23
23
  Then create the 4 CodeBuild projects for testing:
24
24
 
25
- for i in 1 2 3 4 ; do cb deploy demo$i --no-wait ; done
25
+ for i in 1 2 3 4 ; do pipe deploy demo$i --no-wait ; done
26
26
 
27
27
  ## CodePipeline
28
28
 
29
- Let's define a pipeline now with the 4 CodeBuild test projects. First, use `pipe init` to create the starter ``.codepipeline` files. Update your `pipeline.rb` with the following:
29
+ Let's define a pipeline now with the 4 CodeBuild test projects. First, use `pipe init` to create the starter `.codepipeline` files. Update your `pipeline.rb` with the following:
30
30
 
31
31
  codepipeline/pipeline.rb:
32
32
 
@@ -53,6 +53,8 @@ Last, start the pipeline execution:
53
53
 
54
54
  pipe start
55
55
 
56
- That's it!
56
+ That's it! The pipeline will look like this:
57
+
58
+ ![](/img/docs/multiple-codebuild-projects-pipeline.png)
57
59
 
58
60
  {% include prev_next.md %}
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Next Steps
3
- nav_order: 22
3
+ nav_order: 23
4
4
  ---
5
5
 
6
6
  Hopefully, you have a good feel for how codepipeline works now. From here, there are a few resources that can help you continue along:
@@ -21,8 +21,8 @@ The base settings are common and used for all the environments. The other enviro
21
21
 
22
22
  ## Example
23
23
 
24
- cb deploy # will use the development settings since development is the default
25
- PIPE_ENV=production cb deploy # will use the production settings
24
+ pipe deploy # will use the development settings since development is the default
25
+ PIPE_ENV=production pipe deploy # will use the production settings
26
26
 
27
27
  ## Options
28
28
 
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: Structure
3
+ nav_order: 9
4
+ ---
5
+
6
+ The `pipe init` command generates the initial directory structure that looks like this:
7
+
8
+ .codepipeline
9
+ ├── pipeline.rb
10
+ ├── role.rb
11
+ ├── schedule.rb
12
+ ├── settings.yml
13
+ └── webhook.rb
14
+
15
+ The table below states the purpose of each file:
16
+
17
+ File / Directory | Description
18
+ ------------- | -------------
19
+ pipeline.rb | The pipeline defintion. More info: [Pipeline DSL]({% link _docs/dsl/pipeline.md %})
20
+ role.rb | The IAM role defintion. More info: [Role DSL]({% link _docs/dsl/role.md %})
21
+ schedule.rb | The schedule defintion. More info: [Schedule DSL]({% link _docs/dsl/schedule.md %})
22
+ settings.yml | Settings for the codepipeline tool. More info: [Settings]({% link _docs/settings.md %})
23
+ webhook.rb | The webhook defintion. More info: [Webhook DSL]({% link _docs/dsl/webhook.md %})
24
+
25
+ {% include prev_next.md %}
@@ -26,6 +26,7 @@ pipe delete
26
26
  {% highlight sh %}
27
27
  .codepipeline
28
28
  ├── pipeline.rb
29
+ ├── role.rb
29
30
  ├── schedule.rb
30
31
  ├── settings.yml
31
32
  └── webhook.rb
@@ -42,7 +43,7 @@ pipe deploy # infers the pipeline name from the parent folder
42
43
  pipe deploy pipeline-name # explicitly specify pipeline name
43
44
 
44
45
  pipe start # infers the pipeline name from the parent folder
45
- pipe start demo-project # explicitly specify pipeline name
46
+ pipe start pipeline-name # explicitly specify pipeline name
46
47
  {% endhighlight %}
47
48
  </div>
48
49
  </div>
@@ -52,8 +53,8 @@ pipe start demo-project # explicitly specify pipeline name
52
53
  {% highlight ruby %}
53
54
  stage "Source" do
54
55
  github(
55
- source: "tongueroo/demo-cb",
56
- auth_token: ssm("/codebuild/github/tongueroo/oauth_token")
56
+ source: "user/repo",
57
+ auth_token: ssm("/github/user/token")
57
58
  )
58
59
  end
59
60
  stage "DeployStacks" do
@@ -0,0 +1,12 @@
1
+ <section id="timeline">
2
+ <div class="container">
3
+ <div class="row">
4
+ <div class="col-lg-12 text-center">
5
+ <h2 class="section-heading">Demo Pipeline</h2>
6
+ </div>
7
+ </div>
8
+ <div class="row justify-content-center project-pipeline-splash">
9
+ <img src="/img/docs/multiple-codebuild-projects-pipeline.png" />
10
+ </div>
11
+ </div>
12
+ </section>
@@ -4,6 +4,7 @@
4
4
  <li><a href="{% link docs.md %}">Docs</a>
5
5
  <ul class="docs">
6
6
  <li><a href="{% link _docs/install.md %}">Install</a></li>
7
+ <li><a href="{% link _docs/structure.md %}">Structure</a></li>
7
8
  <li><a href="{% link _docs/deploy.md %}">Deploy</a></li>
8
9
  <li><a href="{% link _docs/start.md %}">Start</a></li>
9
10
  <li><a href="{% link _docs/settings.md %}">Settings</a></li>
@@ -361,4 +361,10 @@ blockquote {
361
361
  padding: 12px 24px;
362
362
  margin: 0 0 24px;
363
363
  border-left: 5px solid #eee;
364
+ }
365
+
366
+ .project-pipeline-splash {
367
+ img {
368
+ max-width: 700px;
369
+ }
364
370
  }
data/docs/docs.md CHANGED
@@ -5,20 +5,20 @@ nav_order: 2
5
5
 
6
6
  ## What is codepipeline?
7
7
 
8
- Codepipeline is a tool that simplifies creating and managing [AWS CodePipeline](https://aws.amazon.com/codepipeline/) resources. It provides a DSL to create a Pipeline, Scheduled Event, IAM Role, and Webhook.
8
+ The codepipeline tool provides a DSL that simplifies creating and managing [AWS CodePipeline](https://aws.amazon.com/codepipeline/) resources. You create a Pipeline, Scheduled Event, IAM Role, and Webhook.
9
9
 
10
- The DSL is essentially a wrapper to the CloudFormation for resources like the [CodePipeline Project resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codepipeline-pipeline.html). This means you can **fullly control** and customize of the CodePipeline resources.
10
+ The [codepipeline DSL]({% link _docs/dsl.md %}) is essentially a wrapper to CloudFormation for resources like the [CodePipeline Project resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codepipeline-pipeline.html). This means you can **fully control** and customize of the CodePipeline resources.
11
11
 
12
12
  ## Usage Scenarios
13
13
 
14
14
  Here are some ways to use CodePipeline:
15
15
 
16
- * continously integration and delivery
17
- * deploying code
18
- * building artifacts
16
+ * continuous integration and delivery
17
+ * visualizing the deploy flow
18
+ * building artifacts: Docker images, AMIs, jars, s3 objects, etc
19
19
 
20
20
  ## CodePipeline vs CodeBuild
21
21
 
22
- CodePipeline is a higher level software than CodeBuild. CodeBuild is a managed build service and you can use it to automated tasks. CodePipeline helps you visualize the steps and puts it altogether.
22
+ CodePipeline is higher-level software than CodeBuild. CodeBuild is a managed build service, and you can use it to automate tasks. CodePipeline helps you sequence the steps and puts it all together; providing you with a high-level visualization.
23
23
 
24
24
  {% include prev_next.md %}
data/docs/index.html CHANGED
@@ -22,6 +22,8 @@ subnav: false
22
22
  </div>
23
23
  </header>
24
24
 
25
+ {% include example.html %}
26
+
25
27
  {% include commands.html %}
26
28
 
27
29
  <section class="cta">
data/docs/quick-start.md CHANGED
@@ -33,13 +33,13 @@ Create the starter .codepipeline files in the project.
33
33
 
34
34
  pipe init # generates starter .codepipeline files
35
35
 
36
- An important generated file `.codepipeline/pipeline.rb`. The starter file looks something like this:
36
+ An important generated file is `.codepipeline/pipeline.rb`. The starter file looks something like this:
37
37
 
38
38
  ```ruby
39
39
  stage "Source" do
40
40
  github(
41
- source: "tongueroo/demo-test",
42
- auth_token: ssm("/codebuild/github/tongueroo/oauth_token")
41
+ source: "user/repo", # replace with your repo
42
+ auth_token: ssm("/github/user/token")
43
43
  )
44
44
  end
45
45
 
@@ -48,14 +48,14 @@ stage "Build" do
48
48
  end
49
49
  ```
50
50
 
51
- This is a short pipeline that has 2 stages:
51
+ The pipeline definition is much shorter than typical CloudFormation code. In this short pipeline, there are 2 stages:
52
52
 
53
- 1. downloads the source code from Gitub and uploads it to S3 as a output artifact
54
- 2. starts some codebuild project with the code that was previously uploaded to s3 as the output artifact
53
+ 1. Downloads the source code from Gitub and uploads it to S3 as an output artifact.
54
+ 2. Starts some codebuild project with the code that was previously uploaded to s3 as the input artifact.
55
55
 
56
- Note: you have to create the codebuild projects as a prequisite. The [codebuild.cloud](https://codebuild.cloud) tool helps with this.
56
+ Note, you need to have a codebuild project already created as a prerequisite. The example instructions for that are here: [Create CodeBuild Project]({% link _docs/examples/codebuild-project.md %}).
57
57
 
58
- To define a pipeline, it much shorter than typical CloudFormation code. You can then create the pipeline with a single command:
58
+ You can then deploy or create the pipeline with a single command:
59
59
 
60
60
  pipe deploy
61
61
 
data/docs/support.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: Support
3
- nav_order: 21
3
+ nav_order: 22
4
4
  ---
5
5
 
6
6
  ## Getting Help
@@ -0,0 +1,54 @@
1
+ Examples:
2
+
3
+ codepipe deploy
4
+ codepipe deploy demo # explicitly specify pipeline name
5
+ codepipe deploy demo -b mybranch # specify git branch
6
+
7
+ The pipeline is generated from the DSL and created with CloudFormation. The files that the DSL evaluates are in the `.codepipeline` folder:
8
+
9
+ .codepipeline/pipeline.rb
10
+ .codepipeline/role.rb
11
+ .codepipeline/schedule.rb
12
+ .codepipeline/webhook.rb
13
+
14
+ To create the CodePipeline pipeline, you run:
15
+
16
+ pipe deploy
17
+
18
+ You'll see output that looks something like this:
19
+
20
+ $ pipe deploy
21
+ Generated CloudFormation template at /tmp/codepipeline.yml
22
+ Deploying stack demo-pipe with CodePipeline project demo
23
+ Creating stack demo-pipe. Check CloudFormation console for status.
24
+ Stack name demo-pipe status CREATE_IN_PROGRESS
25
+ Here's the CloudFormation url to check for more details https://console.aws.amazon.com/cloudformation/home?region=us-west-2#/stacks
26
+ Waiting for stack to complete
27
+ 04:14:03AM CREATE_IN_PROGRESS AWS::CloudFormation::Stack demo-pipe User Initiated
28
+ 04:14:06AM CREATE_IN_PROGRESS AWS::IAM::Role IamRole
29
+ 04:14:07AM CREATE_IN_PROGRESS AWS::IAM::Role IamRole Resource creation Initiated
30
+ 04:14:25AM CREATE_COMPLETE AWS::IAM::Role IamRole
31
+ 04:14:28AM CREATE_IN_PROGRESS AWS::CodePipeline::Pipeline Pipeline
32
+ 04:14:29AM CREATE_IN_PROGRESS AWS::CodePipeline::Pipeline Pipeline Resource creation Initiated
33
+ 04:14:29AM CREATE_COMPLETE AWS::CodePipeline::Pipeline Pipeline
34
+ 04:14:31AM CREATE_IN_PROGRESS AWS::CodePipeline::Webhook Webhook
35
+ 04:14:33AM CREATE_IN_PROGRESS AWS::CodePipeline::Webhook Webhook Resource creation Initiated
36
+ 04:14:33AM CREATE_COMPLETE AWS::CodePipeline::Webhook Webhook
37
+ 04:14:35AM CREATE_COMPLETE AWS::CloudFormation::Stack demo-pipe
38
+ Stack success status: CREATE_COMPLETE
39
+ Time took for stack deployment: 35s.
40
+ $
41
+
42
+ ## Explicit Pipeline Name
43
+
44
+ By default, the pipeline name is inferred and is the parent folder that you are within. You can explicitly specify the pipeline name as the first CLI argument:
45
+
46
+ pipe deploy my-pipeline
47
+
48
+ ## Specify Git Branch
49
+
50
+ It is useful to build pipelines with different source git branches. You can pass a `--branch` option to the `pipe deploy` command. The cli `—-branch` option always takes the highest precedence. Example:
51
+
52
+ pipe deploy my-pipeline --branch my-branch
53
+
54
+ Note: When you specify a branch the codepipeline tool actually first updates the pipeline before starting the pipeline execution. This is done because CodePipeline does not natively support specifying the branch. It is discussed more here: [Using Different Branches]({% link _docs/examples/different-branches.md %}).
@@ -0,0 +1,20 @@
1
+ You can start a pipeline with the `pipe start` command. Here's an example:
2
+
3
+ $ pipe start
4
+ Pipeline started: demo
5
+ Please check the CodePipeline console for the status.
6
+ CodePipeline Console: https://us-west-2.console.aws.amazon.com/codesuite/codepipeline/pipelines/demo/view
7
+ Pipeline cli: aws codepipeline get-pipeline-execution --pipeline-execution-id 02579d64-9271-4edc-aa45-bc9629d732bb --pipeline-name demo
8
+ $
9
+
10
+ ## Specifying Code Branch
11
+
12
+ If you would like start a build using a specific code branch you can use the `--branch` or `-b` option. Example:
13
+
14
+ pipe start -b feature-branch
15
+
16
+ ## AWS CLI Equivalent
17
+
18
+ The `pipe start` command is a simple wrapper to the AWS API with the ruby sdk. You can also start pipelines with the `aws codepipeline` cli. Here's the equivalent CLI command:
19
+
20
+ aws codepipeline start-pipeline-execution --name demo
@@ -1,3 +1,3 @@
1
1
  module Codepipe
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codepipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
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-30 00:00:00.000000000 Z
11
+ date: 2019-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -243,6 +243,9 @@ executables:
243
243
  extensions: []
244
244
  extra_rdoc_files: []
245
245
  files:
246
+ - ".codebuild/buildspec.yml"
247
+ - ".codebuild/project.rb"
248
+ - ".codebuild/settings.yml"
246
249
  - ".gitignore"
247
250
  - ".gitmodules"
248
251
  - ".rspec"
@@ -274,15 +277,18 @@ files:
274
277
  - docs/_docs/dsl/sns.md
275
278
  - docs/_docs/dsl/webhook.md
276
279
  - docs/_docs/ecs-deploy.md
280
+ - docs/_docs/examples/codebuild-project.md
277
281
  - docs/_docs/examples/different-branches.md
278
282
  - docs/_docs/examples/multiple-codebuild-projects.md
279
283
  - docs/_docs/install.md
280
284
  - docs/_docs/next-steps.md
281
285
  - docs/_docs/settings.md
282
286
  - docs/_docs/start.md
287
+ - docs/_docs/structure.md
283
288
  - docs/_includes/commands.html
284
289
  - docs/_includes/content.html
285
290
  - docs/_includes/edit-on-github.html
291
+ - docs/_includes/example.html
286
292
  - docs/_includes/footer.html
287
293
  - docs/_includes/google_analytics.html
288
294
  - docs/_includes/head.html
@@ -317,10 +323,8 @@ files:
317
323
  - docs/_sass/_variables.scss
318
324
  - docs/bin/web
319
325
  - docs/docs.md
320
- - docs/dsl/pipeline.md
321
- - docs/dsl/role.md
322
- - docs/dsl/schedule.md
323
326
  - docs/img/docs/codepipeline-output.png
327
+ - docs/img/docs/multiple-codebuild-projects-pipeline.png
324
328
  - docs/img/logos/boltops-logo-full.png
325
329
  - docs/img/logos/boltops-logo.png
326
330
  - docs/img/logos/project-logo.png
@@ -426,7 +430,8 @@ files:
426
430
  - lib/codepipe/help.rb
427
431
  - lib/codepipe/help/completion.md
428
432
  - lib/codepipe/help/completion_script.md
429
- - lib/codepipe/help/hello.md
433
+ - lib/codepipe/help/deploy.md
434
+ - lib/codepipe/help/start.md
430
435
  - lib/codepipe/init.rb
431
436
  - lib/codepipe/pipeline.rb
432
437
  - lib/codepipe/pipeline/s3_bucket.rb
data/docs/dsl/pipeline.md DELETED
@@ -1,75 +0,0 @@
1
- # Pipeline DSL
2
-
3
- .codepipeline/pipeline.rb:
4
-
5
- ```ruby
6
- stage "Source" do
7
- github(
8
- source: "tongueroo/demo-cb",
9
- auth_token: ssm("/codebuild/github/tongueroo/oauth_token")
10
- )
11
- end
12
- stage "DeployStacks" do
13
- codebuild "demo1" # action declaration
14
- codebuild "demo2", "demo3" # will run in parallel. run_order=2
15
- codebuild "demo4" # action declaration
16
- end
17
- ```
18
-
19
- ## Under the Hood
20
-
21
- The convenience methods are shorter and cleaner. However, you have access to a "Full" DSL if needed. The Full DSL are merely the properties of the [AWS::CodePipeline::Pipeline](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-codepipeline-pipeline.html). Here's an example.
22
-
23
- .codepipeline/pipeline.rb:
24
-
25
- ```ruby
26
- stage "Source" do
27
- action(
28
- name: "Source",
29
- action_type_id: {
30
- category: "Source",
31
- owner: "ThirdParty",
32
- provider: "GitHub",
33
- version: "1",
34
- },
35
- run_order: 1,
36
- configuration: {
37
- branch: "master",
38
- o_auth_token: ssm("/codebuild/github/tongueroo/oauth_token"),
39
- owner: "tongueroo",
40
- poll_for_source_changes: "false",
41
- repo: "demo-cb"
42
- },
43
- output_artifacts: [name: "SourceArtifact"]
44
- )
45
- end
46
-
47
- stage "Deploy Stacks" do
48
- # serial
49
- action(
50
- name: "Build1",
51
- action_type_id: {
52
- category: "Build",
53
- owner: "AWS",
54
- provider: "CodeBuild",
55
- version: "1",
56
- },
57
- run_order: 2,
58
- configuration: { project_name: "demo1" },
59
- input_artifacts: [name: "SourceArtifact"],
60
- )
61
- action(
62
- name: "Build2",
63
- action_type_id: {
64
- category: "Build",
65
- owner: "AWS",
66
- provider: "CodeBuild",
67
- version: "1",
68
- },
69
- run_order: 2,
70
- configuration: { project_name: "demo2" },
71
- input_artifacts: [name: "SourceArtifact"],
72
- )
73
- end
74
- ```
75
-
data/docs/dsl/role.md DELETED
@@ -1,66 +0,0 @@
1
- # IAM Role DSL
2
-
3
- You can create the IAM service role associated with the pipeline. Here's an example:
4
-
5
- .codepipeline/role.rb:
6
-
7
- ```ruby
8
- iam_policy("logs", "ssm")
9
- ```
10
-
11
- For more control, here's a longer form:
12
-
13
- ```ruby
14
- iam_policy(
15
- action: [
16
- "logs:CreateLogGroup",
17
- "logs:CreateLogStream",
18
- "logs:PutLogEvents",
19
- "ssm:*",
20
- ],
21
- effect: "Allow",
22
- resource: "*"
23
- )
24
- ```
25
-
26
- You can also create managed iam policy.
27
-
28
- ```ruby
29
- managed_iam_policy("AmazonS3ReadOnlyAccess")
30
- ```
31
-
32
- ## Under the Hood
33
-
34
- The convenience methods merely wrap properties of the [AWS::IAM::Role
35
- CloudFormation Resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html). If you wanted to set the CloudFormation properties more directly, here's an example of using the "Full" DSL.
36
-
37
- .codepipeline/role.rb:
38
-
39
- ```ruby
40
- assume_role_policy_document(
41
- statement: [{
42
- action: ["sts:AssumeRole"],
43
- effect: "Allow",
44
- principal: {
45
- service: ["codepipeline.amazonaws.com"]
46
- }
47
- }],
48
- version: "2012-10-17"
49
- )
50
- path("/")
51
- policies([{
52
- policy_name: "CodePipelineAccess",
53
- policy_document: {
54
- version: "2012-10-17",
55
- statement: [{
56
- action: [
57
- "logs:CreateLogGroup",
58
- "logs:CreateLogStream",
59
- "logs:PutLogEvents",
60
- ],
61
- effect: "Allow",
62
- resource: "*"
63
- }]
64
- }
65
- }])
66
- ```
data/docs/dsl/schedule.md DELETED
@@ -1,20 +0,0 @@
1
- # Schedule DSL
2
-
3
- .codepipeline/schedule.rb:
4
-
5
- ```ruby
6
- rate "1 day"
7
- # or
8
- cron("0 10 * * ? *") # Run at 10:00 am (UTC) every day
9
- ```
10
-
11
- ## Under the Hood
12
-
13
- The convenience methods merely wrap properties of the [AWS::Events::Rule](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-description). If you wanted to set the CloudFormation properties more directly, here's an example of using the "Full" DSL.
14
-
15
- .codepipeline/schedule.rb:
16
-
17
- ```ruby
18
- description "my description"
19
- schedule_expression "rate(1 day)"
20
- ```
@@ -1,5 +0,0 @@
1
- Examples:
2
-
3
- codepipe hello
4
- codepipe hello NAME
5
- codepipe hello NAME --from me