buildkite-sdk 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b6f6f72e11f8e14d2d9733ff117a82636b4acb0e328944a4ebdae19155c5aa9
4
- data.tar.gz: 52b20845627a68c2c3cc537f2cf56ebd591e8b0272e89bea44a8f0360d30b128
3
+ metadata.gz: b3c72dcf7dec4c4b5432313e3d4034c6ed0f8551c7e60cfa474fed37e7c43a0a
4
+ data.tar.gz: b7baca741c77f49eee2c901ddcf65aa8ba412d086a0c368faa54e376b05439e7
5
5
  SHA512:
6
- metadata.gz: 5aad164d05ab9412ad990e592408975a40ad3ef859b779e6b90ac15f54c0946a19ec676e123fafa5cf6d54a3eaedbc5540d57614ccfce557e668699e9e626555
7
- data.tar.gz: 466d0b6c5b5fc8b0abfb7d5177c089a7048f6da5d188c9cf2df69ad3844899b30271fadecdb956af66006ba15d4a5d3198082f1ff1d45097901d3452873f4e05
6
+ metadata.gz: 24f0e1142a091a59af93eb295ed2b409ba0ead7f4efeec24b47e7c869facee15d9daf0858ed773041c3be38939d5763af6ba198edbb06df87dd2610488e23010
7
+ data.tar.gz: af298020ffc4c0fad958d23d25740ee37fd2c9814164a0377b060eb305dc9252ce3bb249f4dbc04648b85ae61c5194a78385a33d43a3fb0f8391fecb9be4411c
data/README.md CHANGED
@@ -1,31 +1,29 @@
1
- # Buildkite
1
+ # buildkite-sdk
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ [![Build status](https://badge.buildkite.com/a95a3beece2339d1783a0a819f4ceb323c1eb12fb9662be274.svg?branch=main)](https://buildkite.com/buildkite/pipeline-sdk)
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/buildkite`. To experiment with that code, run `bin/console` for an interactive prompt.
6
-
7
- ## Installation
8
-
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
-
15
- If bundler is not being used to manage dependencies, install the gem by executing:
16
-
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
5
+ A Ruby SDK for [Buildkite](https://buildkite.com)! 🪁
18
6
 
19
7
  ## Usage
20
8
 
21
- TODO: Write usage instructions here
9
+ Install the package:
10
+
11
+ ```bash
12
+ gem install buildkite-sdk
13
+ ```
22
14
 
23
- ## Development
15
+ Use it in your program:
24
16
 
25
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
17
+ ```ruby
18
+ require "buildkite"
26
19
 
27
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
20
+ pipeline = Buildkite::Pipeline.new
28
21
 
29
- ## Contributing
22
+ pipeline.add_step(
23
+ label: "some-label",
24
+ command: "echo 'Hello, World!'"
25
+ )
30
26
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/buildkite.
27
+ puts pipeline.to_json
28
+ puts pipeline.to_yaml
29
+ ```
@@ -1,3 +1,3 @@
1
1
  module Buildkite
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.1.0".freeze
3
3
  end
data/lib/buildkite.rb CHANGED
@@ -10,6 +10,23 @@ module Buildkite
10
10
  class Pipeline
11
11
  def initialize
12
12
  @steps = []
13
+ @agents = nil
14
+ @env = nil
15
+ @notify = nil
16
+ end
17
+
18
+ def add_agent(key, value)
19
+ @agents = {} if @agents.nil?
20
+ @agents[key] = value
21
+ end
22
+
23
+ def add_environment_variable(key, value)
24
+ @env = {} if @env.nil?
25
+ @env[key] = value
26
+ end
27
+
28
+ def add_notify(notify)
29
+ @notify = notify
13
30
  end
14
31
 
15
32
  # Adds a step to the pipeline.
@@ -31,12 +48,22 @@ module Buildkite
31
48
  self
32
49
  end
33
50
 
51
+ def build
52
+ pipeline = {
53
+ "steps" => @steps
54
+ }
55
+ pipeline["agents"] = @agents if @agents != nil
56
+ pipeline["env"] = @env if @env != nil
57
+ pipeline["notify"] = @notify if @notify != nil
58
+ return pipeline
59
+ end
60
+
34
61
  def to_json(*_args)
35
- JSON.pretty_generate({ steps: @steps }, indent: " ")
62
+ JSON.pretty_generate(self.build, indent: " ")
36
63
  end
37
64
 
38
65
  def to_yaml
39
- { steps: @steps }.to_yaml
66
+ self.build.to_yaml
40
67
  end
41
68
  end
42
69
  end