Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

basic functionality,

      still missing: get config from master branch use for new branch
  • Loading branch information...
commit c63884e447f38f4dd2484ab2fab0c4aa7b2b3b33 1 parent 95209ef
@pxlpnk authored
Showing with 50 additions and 3 deletions.
  1. +50 −3 lib/kraken-build.rb
View
53 lib/kraken-build.rb
@@ -7,8 +7,55 @@
-module Kraken
- module Build
- # Your code goes here...
+module KrakenBuild
+
+ def self.set_config(options = {})
+ @config = options
+ @repository = options[:repository]
+ @github = GithubApi.new(@config)
+ @jenkins = JenkinsApi.new(@config)
+ @jobs = []
+ @branches = []
+
+ @config
end
+
+ def self.get_jenkins_branches
+ @jenkins.get_jobs.map{ |job| job =~ /^#{@repository}\.(.*)$/ && $1 }.compact
+ end
+
+ def self.get_github_branches
+ @github.get_branches
+ end
+
+ def self.run
+ @jobs = get_jenkins_branches
+ @branches = get_github_branches
+
+ create = compute_jobs_to_create
+ create.map do |job|
+ job_name = "#{@repository}.#{job}"
+ puts "creating => #{job_name}"
+ # @jenkins.create_job(job_name,"")
+ # @jenkins.build_job(job_name)
+ end
+
+
+ remove = compute_jobs_to_remove
+ remove.map do |job|
+ job_name = "#{@repository}.#{job}"
+ puts "removing => #{job_name}"
+ @jenkins.remove_job(job_name)
+ end
+
+ end
+
+ def self.compute_jobs_to_create
+ @branches - @jobs
+ end
+
+ def self.compute_jobs_to_remove
+ @jobs - @branches
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.