concourserb 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/concourserb.rb +21 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0db64d613f0838ecced5d80ef387c30b408778c0
4
- data.tar.gz: ee977e8dd110b4a0f4cba60242e7ab6e64057f02
3
+ metadata.gz: 28051c1b07a2adc7639bf5d6810609fb66219fd6
4
+ data.tar.gz: 7c6b58482f0236015d1b4207650468a314f103ad
5
5
  SHA512:
6
- metadata.gz: f4849e4ad64220330373c9708977665fc3de1bafc6b88f09a22cb3d369bf86128d1fa33f85f8b549477ba53ef6e88e1cb171d6bc36c8b2c4c89b51e24f65028b
7
- data.tar.gz: ce8be38d00dfacc9e723290582842fd8729ffd47bb6295f5739cc212d306843910e3b6c3dffe661f9d0c197b7ada5e59deba510d9b18ca9021a574c0efd1c121
6
+ metadata.gz: 5b1294773444f09f07e3a7ed0ff6a1bb70b15e6fdaa556e170fe98a86469ebc4df88860b196a4a6db94d573184e19844a2dc2bd856d3a5a4ce399647577835b6
7
+ data.tar.gz: 05ca20b6f76a4d5670ae0c9bc6db34c14a120957314a04deb4305aac6ee6379cdfab0b607778a24cac979265a5b1e246b2db8a90c0e57be54cfeb71a9a88d67b
data/lib/concourserb.rb CHANGED
@@ -31,6 +31,10 @@ class Concourserb
31
31
  return req("/api/v1/teams/#{@team}/pipelines/#{pipeline_name}/resources/#{resource_name}/versions/#{resource_id}/output_of")
32
32
  end
33
33
 
34
+ def trigger(pipeline_name, job_name)
35
+ return post("/api/v1/teams/#{@team}/pipelines/#{pipeline_name}/jobs/#{job_name}/builds")
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def auth()
@@ -60,4 +64,21 @@ class Concourserb
60
64
  return JSON.parse(response.body)
61
65
  end
62
66
 
67
+ def post(url, post_data={})
68
+ http = Net::HTTP.new(URI.parse(@url).host, URI.parse(@url).port)
69
+ http.use_ssl = true
70
+ request = Net::HTTP::Post.new(url)
71
+ request.set_form_data(post_data)
72
+ request['Content-Type'] = 'application/json'
73
+ request['Cookie'] = "ATC-Authorization=Bearer #{@ATC_auth}"
74
+ response = http.request(request)
75
+ if response.code == 401
76
+ # we got bad auth, so get a new token
77
+ auth()
78
+ request['Cookie'] = "ATC-Authorization=Bearer #{@ATC_auth}"
79
+ response = http.request(request)
80
+ end
81
+ return JSON.parse(response.body)
82
+ end
83
+
63
84
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concourserb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Arwine