TT#96400 repoapi: download artifacts from repos jobs

That will help us to figure out which is the debian package source
name we will use to trigger remove-reprepro-project if necessary

Change-Id: Idd9be9208d8897e6f94dd4bbce328f86cbbfe0f4
pull/3/head
Victor Seva 6 years ago
parent e19659fcfa
commit 96d7217c9e
No known key found for this signature in database
GPG Key ID: B1589889727198E0

@ -17,5 +17,9 @@ from appconf import AppConf
class RepoAPIConf(AppConf):
ARTIFACT_JOB_REGEX = [
".*-repos$",
]
class Meta:
prefix = "repoapi"

@ -103,4 +103,5 @@ JBI_BASEDIR = join(RESULTS_DIR, "jbi_files")
JBI_ARTIFACT_JOBS = [
"fake-release-tools-runner",
]
REPOAPI_ARTIFACT_JOB_REGEX = []
JBI_ALLOWED_HOSTS = ["jenkins-dev.mgm.sipwise.com"]

@ -23,6 +23,7 @@ from django.apps import apps
from .celery import app
from .celery import jbi_parse_hotfix
from .conf import settings
from .utils import is_download_artifacts
from .utils import jenkins_get_artifact
from .utils import jenkins_get_build
from .utils import jenkins_get_console
@ -43,7 +44,7 @@ def get_jbi_files(jbi_id, jobname, buildnumber):
jenkins_get_console(jobname, buildnumber)
path_envVars = jenkins_get_env(jobname, buildnumber)
path_build = jenkins_get_build(jobname, buildnumber)
if jobname in settings.JBI_ARTIFACT_JOBS:
if is_download_artifacts(jobname):
with open(path_build) as data_file:
data = json.load(data_file)
logger.debug("job_info:%s", data)

@ -1,4 +1,4 @@
# Copyright (C) 2017 The Sipwise Team - http://sipwise.com
# Copyright (C) 2017-2020 The Sipwise Team - http://sipwise.com
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@ -12,6 +12,7 @@
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
from django.test import override_settings
from mock import patch
from repoapi import utils
@ -42,3 +43,14 @@ class UtilsTestCase(BaseTest):
ear.return_value = [0, "\n", ""]
val = utils.get_next_release("mr5.4")
self.assertEqual(val, None)
@override_settings(
REPOAPI_ARTIFACT_JOB_REGEX=[".*-repos$"],
JBI_ARTIFACT_JOBS=["fake-release-tools-runner"],
)
def test__is_download_artifacts(self):
self.assertFalse(utils.is_download_artifacts("whatever-binaries"))
self.assertTrue(
utils.is_download_artifacts("fake-release-tools-runner")
)
self.assertTrue(utils.is_download_artifacts("whatever-repos"))

@ -14,6 +14,7 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
import re
import shutil
import subprocess
import urllib.request
@ -167,3 +168,12 @@ def workfront_set_release_target(_id, release):
logger.error("can't set release target. %s. %s", res[1], res[2])
return False
return True
def is_download_artifacts(jobname):
if jobname in settings.JBI_ARTIFACT_JOBS:
return True
for check in settings.REPOAPI_ARTIFACT_JOB_REGEX:
if re.search(check, jobname) is not None:
return True
return False

Loading…
Cancel
Save