diff --git a/app/models/concerns/product_build_lists/abf_workerable.rb b/app/models/concerns/product_build_lists/abf_workerable.rb index e9b01eb90..4c9c2abe4 100644 --- a/app/models/concerns/product_build_lists/abf_workerable.rb +++ b/app/models/concerns/product_build_lists/abf_workerable.rb @@ -34,27 +34,10 @@ module ProductBuildLists::AbfWorkerable end def abf_worker_args - file_name = "#{project.name}-#{commit_hash}" - opts = default_url_options - opts.merge!({user: user.authentication_token, password: ''}) if user.present? - srcpath = url_helpers.archive_url( - project.name_with_owner, - file_name, - 'tar.gz', - opts - ) - - cmd_params = "BUILD_ID=#{id} " - if product.platform.hidden? - token = product.platform.tokens.by_active.where(description: CACHED_CHROOT_TOKEN_DESCRIPTION).first - cmd_params << "TOKEN=#{token.authentication_token} " if token - end - cmd_params << params.to_s - { - id: id, - srcpath: srcpath, - params: cmd_params, + id: id, + srcpath: abf_worker_srcpath, + params: abf_worker_params, time_living: time_living, main_script: main_script, platform: { @@ -66,4 +49,36 @@ module ProductBuildLists::AbfWorkerable } end + # Private: Get URL to project archive. + # + # Returns the String. + def abf_worker_srcpath + file_name = "#{project.name}-#{commit_hash}" + opts = default_url_options + opts.merge!({user: user.authentication_token, password: ''}) if user.present? + url_helpers.archive_url( + project.name_with_owner, + file_name, + 'tar.gz', + opts + ) + end + + # Private: Get params for ABF worker task. + # + # Returns the String with space separated params. + def abf_worker_params + p = { + 'BUILD_ID' => id, + 'PROJECT' => project.name_with_owner, + 'PROJECT_VERSION' => project_version, + 'COMMIT_HASH' => commit_hash, + } + if product.platform.hidden? + token = product.platform.tokens.by_active.where(description: CACHED_CHROOT_TOKEN_DESCRIPTION).first + p.merge!('TOKEN' => token.authentication_token) if token + end + p.map{ |k, v| "#{k}=#{v}" } * ' ' + ' ' + params.to_s + end + end diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index d5e3bfd79..cc775e3eb 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -69,3 +69,17 @@ en: status: Select a status product_name: Enter the name of product here. product_id: Enter the ID of product build list here. + params: "ARCH=x86_64" + hints: + product_build_list: + params_html: > + Enter above a params which will be used for running of Main script. +
+ By default passes next params: + diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index ee0f7a07c..83031b52c 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -69,3 +69,17 @@ ru: status: Выберите статус product_name: Введите название продукта здесь. product_id: Введите Id сборочного листа продукта здесь. + params: "ARCH=x86_64" + hints: + product_build_list: + params_html: > + Введите выше параметры, с которыми будет запускаться Основной скрипт. +
+ По умолчанию передаются следующие параметры: + diff --git a/spec/models/product_build_list_spec.rb b/spec/models/product_build_list_spec.rb index 6014d66e0..63ad93dfc 100644 --- a/spec/models/product_build_list_spec.rb +++ b/spec/models/product_build_list_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe ProductBuildList do before { stub_symlink_methods } + let(:pbl) { FactoryGirl.build(:product_build_list) } + context 'ensures that validations and associations exist' do before do arch = double(:arch, id: 123, name: 'x86_64') @@ -35,4 +37,24 @@ describe ProductBuildList do it { is_expected.to allow_mass_assignment_of(:status) } it { is_expected.to allow_mass_assignment_of(:base_url) } end + + describe '#abf_worker_srcpath' do + it 'returns URL to project archive' do + expect(pbl.send :abf_worker_srcpath).to be_present + end + end + + describe '#abf_worker_params' do + let(:pbl) { FactoryGirl.build(:product_build_list, id: 1234, params: 'ARCH=x86') } + + it 'returns String with params' do + expect(pbl.send :abf_worker_params).to eq "BUILD_ID=#{pbl.id} PROJECT=#{pbl.project.name_with_owner} PROJECT_VERSION=#{pbl.project_version} COMMIT_HASH=#{pbl.commit_hash} ARCH=x86" + end + end + + describe '#abf_worker_args' do + it 'returns Hash with args' do + expect(pbl.send :abf_worker_args).to be_present + end + end end