def _run(self): """ Build a package in Jenkins. """ pkg_name = util.package_name() branch_name = util.current_branch() jenkins = util.jenkins_connection() if branch_name.startswith("patch-queue/"): log.error("%s a patch-queue branch" % branch_name) msg = 'You can switch to the debian branch with "gbp pq switch"' raise SystemExit(msg) log.info( "building %s branch %s at %s", pkg_name, branch_name, posixpath.join(jenkins.url, "job", "build-package") ) job_params = {"PKG_NAME": pkg_name, "BRANCH": branch_name} if self._has_broken_build_job(): jenkins.build_job = types.MethodType(_build_job_fixed, jenkins) jenkins.build_job("build-package", parameters=job_params, token=jenkins.password)
def _run(self): """ Build a package in Jenkins. """ pkg_name = util.package_name() branch_name = util.current_branch() jenkins = util.jenkins_connection() if branch_name.startswith('patch-queue/'): log.error('%s a patch-queue branch' % branch_name) msg = 'You can switch to the debian branch with "gbp pq switch"' raise SystemExit(msg) log.info('building %s branch %s at %s', pkg_name, branch_name, posixpath.join(jenkins.url, 'job', 'build-package')) job_params = {'PKG_NAME': pkg_name, 'BRANCH': branch_name} if self._has_broken_build_job(): jenkins.build_job = types.MethodType(_build_job_fixed, jenkins) jenkins.build_job('build-package', parameters=job_params, token=jenkins.password)
def _run(self, distro): """ Build a package on the local system, using pbuilder. """ pkg_name = util.package_name() os.environ['BUILDER'] = 'pbuilder' j_arg = self._get_j_arg(cpu_count()) pbuilder_cache = '/var/cache/pbuilder/base-%s-amd64.tgz' % distro if not os.path.isfile(pbuilder_cache): cmd = ['sudo', 'pbuilder', 'create', '--debootstrapopts', '--variant=buildd', '--basetgz', pbuilder_cache, '--distribution', distro] log.info('initializing pbuilder cache %s', pbuilder_cache) subprocess.check_call(cmd) # TODO: we should also probably check parent dir for leftovers and warn # the user to delete them (or delete them ourselves?) cmd = ['gbp', 'buildpackage', '--git-dist=%s' % distro, '--git-arch=amd64', '--git-verbose', '--git-pbuilder', j_arg, '-us', '-uc'] log.info('building %s with pbuilder', pkg_name) subprocess.check_call(cmd)
def _run(self): """ Build a package in Jenkins. """ pkg_name = util.package_name() branch_name = util.current_branch() jenkins = util.jenkins_connection() if branch_name.startswith('patch-queue/'): log.error('%s is a patch-queue branch' % branch_name) msg = 'You can switch to the debian branch with "gbp pq switch"' raise SystemExit(msg) log.info('building %s branch %s at %s', pkg_name, branch_name, posixpath.join(jenkins.url, 'job', 'build-package')) job_params = {'PKG_NAME': pkg_name, 'BRANCH': branch_name} queue_number = jenkins.build_job('build-package', parameters=job_params, token=jenkins.password) # Job is now queued, not yet running. log.info('Waiting for build queue #%d' % queue_number) log.info('This may be safely interrupted...') queue_item = jenkins.get_queue_item(queue_number) while 'executable' not in queue_item: try: log.info('queue state: %s' % queue_item['why']) sleep(2) queue_item = jenkins.get_queue_item(queue_number) except KeyboardInterrupt: # We have no build_number, so just print a general message with # a basic URL for the user to check. print('') print('Build is queued for starting at %s' % jenkins.url) raise SystemExit(1) # Job is now running. build_number = queue_item['executable']['number'] # Pass the rest over to the "watch-build" command. watcher = WatchBuild(['watch']) watcher.watch(build_number)
def _run(self, distro): """ Build a package on the local system, using pbuilder. """ pkg_name = util.package_name() os.environ['BUILDER'] = 'pbuilder' j_arg = self._get_j_arg(cpu_count()) pbuilder_cache = '/var/cache/pbuilder/base-%s-amd64.tgz' % distro setup_pbuilder_cache(pbuilder_cache, distro) util.setup_pristine_tar_branch() # TODO: we should also probably check parent dir for leftovers and warn # the user to delete them (or delete them ourselves?) cmd = [ 'gbp', 'buildpackage', '--git-dist=%s' % distro, '--git-arch=amd64', '--git-verbose', '--git-pbuilder', j_arg, '-us', '-uc' ] log.info('building %s with pbuilder', pkg_name) subprocess.check_call(cmd)
def test_bad_directory(self, testpkg, monkeypatch): monkeypatch.chdir(testpkg.join('debian')) with pytest.raises(RuntimeError) as e: util.package_name() expected = 'testpkg/debian is not the root of a git clone' assert expected in str(e.value)
def test_package_name(self, testpkg): assert util.package_name() == 'testpkg'
def test_package_name(self, tmpdir, monkeypatch): tmpdir.mkdir('mypkg') monkeypatch.chdir(tmpdir.join('mypkg')) assert util.package_name() == 'mypkg'
def test_package_name(self, testpkg, monkeypatch): assert util.package_name() == 'testpkg'