Exemple #1
0
def run(schmenkins, job, info, build):
    source_job = schmenkins.get_job(itpl(info['project'], build.parameters()))
    if info['which-build'] == 'specific-build':
        source_build = SchmenkinsBuild(source_job,
                                       build_number=itpl(info['build-number'],
                                                         build.parameters()))
    else:
        raise UnsupportedConfig(info['which-build'])

    target_dir = job.workspace()

    if 'target' in info:
        target_dir = os.path.join(target_dir, info['target'])

    ensure_dir(target_dir)

    source_dir = source_build.artifact_dir()

    fileset = formic.FileSet(directory=source_dir,
                             include=info['filter'])

    for f in fileset.qualified_files(absolute=False):
        shutil.copy(os.path.join(source_dir, f),
                    os.path.join(target_dir, f))
Exemple #2
0
    def test_itpl(self):
        d = {'abc': 'def',
             'AbC': 'ghi'}

        self.assertEquals(utils.itpl('123${abc}456', d), '123def456')
        self.assertEquals(utils.itpl('123${AbC}456', d), '123ghi456')
        self.assertEquals(utils.itpl('123${Ab}456', d), '123456')
        self.assertEquals(utils.itpl('123$Ab456', d), '123')
        self.assertEquals(utils.itpl('123$AbC456', d), '123')
        self.assertEquals(utils.itpl('123$AbC', d), '123ghi')
def _publish(schmenkins, job, info, build):
    if info['project'] not in schmenkins.jobs:
        raise Exception('Unknown job %s' % (info['project'],))

    if 'condition' in info:
        if info['condition'] == 'UNSTABLE_OR_BETTER':
            if build.state.state == 'FAILED':
                return
        else:
            raise UnsupportedConfig('%s' % (info['condition'],))

    parameters = {}

    for l in info['predefined-parameters'].split('\n'):
         if '=' not in l:
             continue
         k, v = l.split('=', 1)
         parameters[k] = itpl(v, build.parameters())

    trigger_job = schmenkins.get_job(info['project'])
    triggered_build = trigger_job.run(parameters=parameters)