2013-08-12 13:27:50 -07:00
|
|
|
# Copyright 2013 OpenStack Foundation
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
# not use this file except in compliance with the License. You may obtain
|
|
|
|
# a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
|
2014-06-19 10:41:35 -07:00
|
|
|
import re
|
|
|
|
|
2013-09-20 14:58:20 -07:00
|
|
|
|
2013-07-29 10:46:53 -07:00
|
|
|
def set_log_url(item, job, params):
|
2013-07-09 10:53:27 -07:00
|
|
|
if hasattr(item.change, 'refspec'):
|
2014-12-12 14:54:41 +11:00
|
|
|
path = "%s/%s/%s/%s/" % (
|
2013-07-09 10:53:27 -07:00
|
|
|
params['ZUUL_CHANGE'][-2:], params['ZUUL_CHANGE'],
|
|
|
|
params['ZUUL_PATCHSET'], params['ZUUL_PIPELINE'])
|
2013-08-01 15:54:12 -07:00
|
|
|
elif hasattr(item.change, 'ref'):
|
2014-12-12 14:54:41 +11:00
|
|
|
path = "%s/%s/%s/" % (
|
2013-07-09 10:53:27 -07:00
|
|
|
params['ZUUL_NEWREV'][:2], params['ZUUL_NEWREV'],
|
|
|
|
params['ZUUL_PIPELINE'])
|
2013-08-01 15:54:12 -07:00
|
|
|
else:
|
2015-03-10 11:55:24 -07:00
|
|
|
path = params['ZUUL_PIPELINE'] + '/'
|
2013-07-09 10:53:27 -07:00
|
|
|
params['BASE_LOG_PATH'] = path
|
2014-12-17 12:09:59 +11:00
|
|
|
params['LOG_PATH'] = path + '%s/%s/' % (job.name,
|
|
|
|
params['ZUUL_UUID'][:7])
|
2013-08-12 13:27:50 -07:00
|
|
|
|
|
|
|
|
2014-06-19 10:41:35 -07:00
|
|
|
def reusable_node(item, job, params):
|
|
|
|
if 'OFFLINE_NODE_WHEN_COMPLETE' in params:
|
|
|
|
del params['OFFLINE_NODE_WHEN_COMPLETE']
|
|
|
|
|
|
|
|
|
2015-12-22 06:03:57 +00:00
|
|
|
def set_node_options(item, job, params):
|
2016-01-07 17:29:18 -08:00
|
|
|
# Force tox to pass through ZUUL_ variables
|
|
|
|
zuul_params = [x for x in params.keys() if x.startswith('ZUUL_')]
|
2016-01-08 12:08:33 -08:00
|
|
|
params['TOX_TESTENV_PASSENV'] = ' '.join(zuul_params)
|
2015-10-30 17:36:39 +02:00
|
|
|
# Set up log url parameter for all jobs
|
2013-08-12 13:27:50 -07:00
|
|
|
set_log_url(item, job, params)
|
2014-06-19 10:41:35 -07:00
|
|
|
# Default to single use node. Potentially overriden below.
|
|
|
|
# Select node to run job on.
|
2013-08-12 13:27:50 -07:00
|
|
|
params['OFFLINE_NODE_WHEN_COMPLETE'] = '1'
|
2015-09-25 08:10:18 +02:00
|
|
|
proposal_re = r'^.*(merge-release-tags|(propose|upstream)-(.*?)-(constraints-.*|updates?|update-liberty))$' # noqa
|
2015-10-07 15:56:50 -07:00
|
|
|
release_re = r'^.*-(forge|jenkinsci|mavencentral|pypi-(both|wheel)|npm)-upload$'
|
2015-07-28 12:28:50 -04:00
|
|
|
hook_re = r'^hook-(.*?)-(rtfd)$'
|
2015-12-21 20:58:43 +00:00
|
|
|
# jobs run on the persistent proposal and release workers
|
2015-07-28 12:28:50 -04:00
|
|
|
if (re.match(proposal_re, job.name) or re.match(release_re, job.name) or
|
|
|
|
re.match(hook_re, job.name)):
|
2014-06-19 10:41:35 -07:00
|
|
|
reusable_node(item, job, params)
|