#470: Pass extra variables for building of product build lists.
This commit is contained in:
parent
12c98b9a08
commit
b46d44395d
|
@ -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
|
||||
|
|
|
@ -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 <i>Main script</i>.
|
||||
<br/>
|
||||
By default passes next params:
|
||||
<ul class='help-block'>
|
||||
<li><i>BUILD_ID</i> - The build ID.</li>
|
||||
<li><i>PROJECT</i> - The project name (e.g. abf/rosa-build).</li>
|
||||
<li><i>PROJECT_VERSION</i> - The version of project.</li>
|
||||
<li><i>COMMIT_HASH</i> - The commit hash.</li>
|
||||
<li><i>TOKEN</i> - The token for access to hidden platform.</li>
|
||||
</ul>
|
||||
|
|
|
@ -69,3 +69,17 @@ ru:
|
|||
status: Выберите статус
|
||||
product_name: Введите название продукта здесь.
|
||||
product_id: Введите Id сборочного листа продукта здесь.
|
||||
params: "ARCH=x86_64"
|
||||
hints:
|
||||
product_build_list:
|
||||
params_html: >
|
||||
Введите выше параметры, с которыми будет запускаться <i>Основной скрипт</i>.
|
||||
<br/>
|
||||
По умолчанию передаются следующие параметры:
|
||||
<ul class='help-block'>
|
||||
<li><i>BUILD_ID</i> - ID сборки.</li>
|
||||
<li><i>PROJECT</i> - Название проекта (например abf/rosa-build).</li>
|
||||
<li><i>PROJECT_VERSION</i> - Версия проекта.</li>
|
||||
<li><i>COMMIT_HASH</i> - Хэш коммита.</li>
|
||||
<li><i>TOKEN</i> - Токен для доступа к закрытой платформе.</li>
|
||||
</ul>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue