buildkite-builder 2.2.0 → 2.3.0
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 -1
- data/README.md +18 -12
- data/VERSION +1 -1
- data/lib/buildkite/builder/commands/run.rb +7 -2
- data/lib/buildkite/builder/pipeline.rb +10 -4
- data/lib/buildkite/builder.rb +3 -0
- data/lib/buildkite/pipelines/command.rb +23 -17
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c6eaf580c5dea018a834cf11f76e5d1d1aa13792fda9b9d513993e53f56f0a7
|
4
|
+
data.tar.gz: 5958862296476f8421ccb62fb0f23e7fef86302fdf354b00c8db9885f71691f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42719a13b6515e91edd391ea18e3f3e18b8db49ec4e4b36d81d0388a701a7567c63992b72860c20f1041b378c6b7a5475c2f5c33a2e454886c3f8a8a678d0b75
|
7
|
+
data.tar.gz: f19d241a0507f434f778560bb4bf5b10dacbe1f8e743718257ac235b433cffd69f472b4d8eb30f9b3ceb28401cb241bda022743a29ffa8f72449964b3a091fa2
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# Buildkite Builder [![Build status](https://badge.buildkite.com/a26bf804e9a93fb118d29824d5695a601a248ceec51591be23.svg?branch=main)](https://buildkite.com/gusto-open-source/buildkite-builder/builds?branch=main)
|
2
2
|
|
3
3
|
## Introduction
|
4
|
+
|
4
5
|
Buildkite Builder (BKB) is a Buildkite pipeline builder written in Ruby. It allows you to build your pipeline with a Ruby DSL for dynamically generated pipeline steps.
|
5
6
|
|
6
7
|
## Gem Installation (optional)
|
7
8
|
|
8
|
-
There are 2 components to this toolkit. The `buildkite-builder`
|
9
|
+
There are 2 components to this toolkit. The `buildkite-builder` RubyGem and the `buildkite-builder` Docker image. You technically only need the image to use Buildkite Builder, but installing the gem in your repo helps you preview your pipeline during development.
|
9
10
|
|
10
11
|
To install the gem, add this line to your application's Gemfile:
|
11
12
|
|
@@ -16,7 +17,7 @@ gem 'buildkite-builder'
|
|
16
17
|
The gem provides a command line tool that lets you perform various operations on your pipelines:
|
17
18
|
|
18
19
|
```shell
|
19
|
-
|
20
|
+
buildkite-builder help
|
20
21
|
```
|
21
22
|
|
22
23
|
## Pipeline Installation
|
@@ -33,23 +34,26 @@ steps:
|
|
33
34
|
```
|
34
35
|
|
35
36
|
Some things to note:
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
|
38
|
+
- The `label` can be whatever you like.
|
39
|
+
- You'll want to update the `docker` plugin version from time to time.
|
40
|
+
- You can update the `buildkite-builder` version by bumping the Docker image tag.
|
39
41
|
|
40
42
|
## Usage
|
41
43
|
|
42
44
|
💡 We have a [Showcase pipeline](https://buildkite.com/gusto-open-source/showcase/builds/latest?branch=main) (defined in [`.buildkite/pipelines/showcase/pipeline.rb`](https://github.com/Gusto/buildkite-builder/blob/main/.buildkite/pipelines/showcase/pipeline.rb)) that, well, showcases some of the features and possibilities with Buildkite Builder. Sometimes the best way to learning something is seeing how it's used.
|
43
45
|
|
44
46
|
At its core, BKB is really just a YAML builder. This tool allows you to scale your needs when it comes to building a Buildkite pipeline. Your pipeline can be as straight forward as you'd like, or as complex as you need. Since you have Ruby at your disposal, you can do some cool things like:
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
|
48
|
+
- Perform pre-build code/diff analysis to determine whether or not to to add a step to the pipeline.
|
49
|
+
- Reorder pipeline steps dynamically.
|
50
|
+
- Augment your pipeline steps with BKB processors.
|
48
51
|
|
49
52
|
### Pipeline Files
|
53
|
+
|
50
54
|
Your repo can contain as many pipeline definitions as you'd like. By convention, pipeline file structure are as such:
|
51
55
|
|
52
|
-
```
|
56
|
+
```console
|
53
57
|
.buildkite/
|
54
58
|
pipelines/
|
55
59
|
<your-pipeline1-slug>/
|
@@ -95,7 +99,7 @@ If the step type or attribute exists in Buildkite docs, then it should exist in
|
|
95
99
|
|
96
100
|
If your pipeline has a lot of steps, you should consider using Step Templates. Templates allow you to break out your build steps into reusable template files.
|
97
101
|
|
98
|
-
```
|
102
|
+
```console
|
99
103
|
.buildkite/
|
100
104
|
pipelines/
|
101
105
|
foobar-widget/
|
@@ -108,6 +112,7 @@ If your pipeline has a lot of steps, you should consider using Step Templates. T
|
|
108
112
|
A template is basically a step that was extracted from the pipeline:
|
109
113
|
|
110
114
|
`.buildkite/pipelines/foobar-widget/templates/rspec.rb`
|
115
|
+
|
111
116
|
```ruby
|
112
117
|
Buildkite::Builder.template do
|
113
118
|
label "Rspec", emoji: :rspec
|
@@ -118,6 +123,7 @@ end
|
|
118
123
|
You can then include the template into the the pipeline once or as many time as you need. The template name will be the name of the file (without the extension).
|
119
124
|
|
120
125
|
`.buildkite/pipelines/foobar-widget/pipeline.rb`
|
126
|
+
|
121
127
|
```ruby
|
122
128
|
Buildkite::Builder.pipeline do
|
123
129
|
command(:rspec)
|
@@ -137,7 +143,7 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
137
143
|
|
138
144
|
## Contributing
|
139
145
|
|
140
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/gusto/buildkite-builder
|
146
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/gusto/buildkite-builder>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/gusto/buildkite-builder/blob/main/CODE_OF_CONDUCT.md).
|
141
147
|
|
142
148
|
## License
|
143
149
|
|
@@ -145,4 +151,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
145
151
|
|
146
152
|
## Code of Conduct
|
147
153
|
|
148
|
-
Everyone interacting in the Buildkite::Builder project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/gusto/buildkite-builder/blob/main/CODE_OF_CONDUCT.md).
|
154
|
+
Everyone interacting in the `Buildkite::Builder` project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/gusto/buildkite-builder/blob/main/CODE_OF_CONDUCT.md).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
@@ -15,8 +15,13 @@ module Buildkite
|
|
15
15
|
|
16
16
|
# This entrypoint is for running on CI. It expects certain environment
|
17
17
|
# variables to be set. It also uploads the pipeline to Buildkite.
|
18
|
-
log.info "
|
19
|
-
|
18
|
+
log.info "+++ 🧰 #{'Buildkite Builder'.color(:springgreen)} ─ #{relative_pipeline_path.to_s.yellow}"
|
19
|
+
|
20
|
+
if Buildkite::Pipelines::Command.meta_data(:exists, Builder::META_DATA.fetch(:job))
|
21
|
+
log.info 'Pipeline already uploaded'.color(:dimgray)
|
22
|
+
else
|
23
|
+
Pipeline.new(pipeline_path, logger: log).upload
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
private
|
@@ -41,19 +41,23 @@ module Buildkite
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def upload
|
44
|
+
# Generate the pipeline YAML first.
|
45
|
+
contents = to_yaml
|
46
|
+
|
47
|
+
upload_artifacts
|
48
|
+
|
44
49
|
# Upload the pipeline.
|
45
50
|
Tempfile.create(['pipeline', '.yml']) do |file|
|
46
51
|
file.sync = true
|
47
|
-
file.write(
|
52
|
+
file.write(contents)
|
48
53
|
|
49
54
|
logger.info '+++ :paperclip: Uploading pipeline.yml as artifact'
|
50
55
|
Buildkite::Pipelines::Command.artifact!(:upload, file.path)
|
51
56
|
logger.info '+++ :pipeline: Uploading pipeline'
|
52
57
|
Buildkite::Pipelines::Command.pipeline!(:upload, file.path)
|
58
|
+
logger.info "+++ :toolbox: Setting job meta-data to #{Buildkite.env.job_id.color(:yellow)}"
|
59
|
+
Buildkite::Pipelines::Command.meta_data!(:set, Builder::META_DATA.fetch(:job), Buildkite.env.job_id)
|
53
60
|
end
|
54
|
-
|
55
|
-
logger.info '+++ :paperclip: Uploading artifacts'
|
56
|
-
upload_artifacts
|
57
61
|
end
|
58
62
|
|
59
63
|
def to_h
|
@@ -85,6 +89,8 @@ module Buildkite
|
|
85
89
|
def upload_artifacts
|
86
90
|
return if artifacts.empty?
|
87
91
|
|
92
|
+
logger.info "+++ :paperclip: Uploading #{artifacts.size.to_s.color(:yellow)} artifact#{'s' if artifacts.size != 1}"
|
93
|
+
|
88
94
|
artifacts.each do |path|
|
89
95
|
if File.exist?(path)
|
90
96
|
Buildkite::Pipelines::Command.artifact!(:upload, path)
|
data/lib/buildkite/builder.rb
CHANGED
@@ -27,6 +27,9 @@ module Buildkite
|
|
27
27
|
autoload :PluginManager, File.expand_path('builder/plugin_manager', __dir__)
|
28
28
|
|
29
29
|
BUILDKITE_DIRECTORY_NAME = Pathname.new('.buildkite').freeze
|
30
|
+
META_DATA = {
|
31
|
+
job: 'buildkite-builder:job'
|
32
|
+
}.freeze
|
30
33
|
|
31
34
|
class << self
|
32
35
|
def root(start_path: Dir.pwd, reset: false)
|
@@ -4,29 +4,35 @@ module Buildkite
|
|
4
4
|
module Pipelines
|
5
5
|
class Command
|
6
6
|
BIN_PATH = 'buildkite-agent'
|
7
|
+
COMMANDS = %w(
|
8
|
+
pipeline
|
9
|
+
artifact
|
10
|
+
annotate
|
11
|
+
meta_data
|
12
|
+
)
|
7
13
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def self.pipeline(subcommand, *args)
|
13
|
-
new(:pipeline, subcommand, *args).run
|
14
|
-
end
|
14
|
+
class << self
|
15
|
+
def pipeline(subcommand, *args)
|
16
|
+
new(:pipeline, subcommand, *args).run
|
17
|
+
end
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
+
def artifact(subcommand, *args)
|
20
|
+
new(:artifact, subcommand, *args).run
|
21
|
+
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
def annotate(body, *args)
|
24
|
+
new(:annotate, body, *args).run
|
25
|
+
end
|
23
26
|
|
24
|
-
|
25
|
-
|
27
|
+
def meta_data(subcommand, *args)
|
28
|
+
new(:'meta-data', subcommand, *args).run
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
|
-
|
29
|
-
|
32
|
+
COMMANDS.each do |command|
|
33
|
+
define_singleton_method("#{command}!") do |*args|
|
34
|
+
abort unless public_send(command, *args)
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
def initialize(command, subcommand, *args)
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkite-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ngan Pham
|
8
8
|
- Andrew Lee
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rainbow
|
@@ -181,7 +181,7 @@ metadata:
|
|
181
181
|
source_code_uri: https://github.com/Gusto/buildkite-builder
|
182
182
|
changelog_uri: https://github.com/Gusto/buildkite-builder/blob/master/CHANGELOG.md
|
183
183
|
bug_tracker_uri: https://github.com/Gusto/buildkite-builder/issues
|
184
|
-
post_install_message:
|
184
|
+
post_install_message:
|
185
185
|
rdoc_options: []
|
186
186
|
require_paths:
|
187
187
|
- lib
|
@@ -196,8 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
- !ruby/object:Gem::Version
|
197
197
|
version: '0'
|
198
198
|
requirements: []
|
199
|
-
rubygems_version: 3.
|
200
|
-
signing_key:
|
199
|
+
rubygems_version: 3.1.6
|
200
|
+
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: A gem for programmatically creating Buildkite pipelines.
|
203
203
|
test_files: []
|