Class: Pipeline
Instance Attribute Summary collapse
-
#apps ⇒ Object
Returns the value of attribute apps.
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #app(app_id, project_name, platform_type, url_segment = nil) ⇒ Object
- #appVersion(app_id) ⇒ Object
- #bg_deploy(environment, paas, force = false) ⇒ Object
- #configure(environment) ⇒ Object
- #deploy(environment, paas, force = false) ⇒ Object
- #eachAppDeployment(environment) ⇒ Object
-
#initialize(id, artifact_repo, output, options) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #load!(environment, deploy_shipcloud) ⇒ Object
- #update(environment, from_upstream_env) ⇒ Object
Methods included from ApiHelper
Constructor Details
#initialize(id, artifact_repo, output, options) ⇒ Pipeline
Returns a new instance of Pipeline.
6 7 8 9 10 11 12 |
# File 'lib/conan/pipeline.rb', line 6 def initialize(id, artifact_repo, output, ) @id = id @artifact_repo = artifact_repo @output = output @apps = {} @options = end |
Instance Attribute Details
#apps ⇒ Object
Returns the value of attribute apps.
4 5 6 |
# File 'lib/conan/pipeline.rb', line 4 def apps @apps end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/conan/pipeline.rb', line 4 def id @id end |
Instance Method Details
#app(app_id, project_name, platform_type, url_segment = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/conan/pipeline.rb', line 14 def app(app_id, project_name, platform_type, url_segment=nil) if (@options[:'deploy-app-name'].nil?) || (@options[:'deploy-app-name'] == app_id.to_s) puts "No app specified, or we matched the specified app: #{@options[:'deploy-app-name']}" @apps[app_id] = case platform_type when :jvm JvmApp.new(app_id, project_name, @artifact_repo, @options, url_segment) when :rails_zip RailsZipApp.new(app_id, project_name, @artifact_repo, @options, url_segment) else raise "unknown platform type: #{platform_type}" end else puts "App #{app_id} doesn't match specified app #{@options[:'deploy-app-name']}, skipping" end end |
#appVersion(app_id) ⇒ Object
30 31 32 |
# File 'lib/conan/pipeline.rb', line 30 def appVersion(app_id) @apps[app_id].version end |
#bg_deploy(environment, paas, force = false) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/conan/pipeline.rb', line 83 def bg_deploy(environment, paas, force=false) apps = [] eachAppDeployment(environment) { |app, deploy| if (force or !app.isDeployedAt(deploy.manifest_url(app))) paas.bg_deploy(@output.workingDir(app), app, deploy) end } end |
#configure(environment) ⇒ Object
68 69 70 |
# File 'lib/conan/pipeline.rb', line 68 def configure(environment) eachAppDeployment(environment) { |app, deploy| @output.writeConfiguration(app, deploy) } end |
#deploy(environment, paas, force = false) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/conan/pipeline.rb', line 72 def deploy(environment, paas, force=false) eachAppDeployment(environment) { |app, deploy| work_dir = @output.workingDir(app) if (force) paas.deploy(work_dir, app, deploy, true) else paas.deploy(work_dir, app, deploy) unless app.isDeployedAt(deploy.manifest_url(app)) end } end |
#eachAppDeployment(environment) ⇒ Object
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/conan/pipeline.rb', line 92 def eachAppDeployment(environment) selected_deployments = environment.deployments.select{ |d| @deploy_shipcloud.nil? || d.shipcloud == @deploy_shipcloud } puts "WARNING no deploys selected: #{@deploy_shipcloud}" if selected_deployments.empty? selected_deployments.each do |d| d.app_ids.each do |a| app = @apps[a] yield app, d unless app.nil? end end end |
#load!(environment, deploy_shipcloud) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/conan/pipeline.rb', line 34 def load!(environment, deploy_shipcloud) eachAppDeployment(environment) { |app, deploy| # load the persisted meta-data @output.loadAppMetadataFromDeploymentIfExists(app, deploy) } @deploy_shipcloud = deploy_shipcloud end |
#update(environment, from_upstream_env) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/conan/pipeline.rb', line 42 def update(environment, from_upstream_env) @apps.values.each { |app| puts '' if !(@options[:'deploy-app-version'].nil?) puts "Using version from options: #{@options[:'deploy-app-version']}" app.findRequestedVersion(@options[:'deploy-app-version']) elsif (from_upstream_env) # promote versions from an upstream deploy # TODO: this needs improving puts "Promote #{app.id} from #{from_upstream_env.id} to #{environment.id}" upstream_deploy = from_upstream_env.deployments.select { |d| d.app_ids.select {|x| x == app.id }.size > 0 }.first @output.loadAppMetadataFromDeployment(app, upstream_deploy) else puts "Find latest #{app.artifact_id}" # lookup most recent from repo app.findRequestedVersion('LATEST') end @output.clean(app, environment) # download artifacts @output.provision(app) } # write out deployment artifact meta-data eachAppDeployment(environment) { |app, deploy| @output.writeArtifactMetadata(app, deploy) } end |