From d6d518f6aa8d0715cdfbd9bf29361576676d0d2c Mon Sep 17 00:00:00 2001 From: Martin Kluson Date: Wed, 21 Dec 2016 16:12:26 +0100 Subject: [PATCH] Calling jenkins job builder with no config file I come with better solution for issue #41. Instead of injecting password to all jobs, which update or create some other job, I change the way how xml for updating/creating job is obtained from source yaml file. In case jekins job builder does not need access to Jenkins instance, it is called without any config file. --- build-on-push/jjb/platform-commit.yaml | 3 --- build-on-push/platform_ci/platform_ci/jjb.py | 9 ++++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/build-on-push/jjb/platform-commit.yaml b/build-on-push/jjb/platform-commit.yaml index 2d1a61e..c889f71 100644 --- a/build-on-push/jjb/platform-commit.yaml +++ b/build-on-push/jjb/platform-commit.yaml @@ -68,9 +68,6 @@ job-commit-dispatcher.sh "{component}" "$GIT_BRANCH" "{github-user}" "{platform-ci-branch}" wrappers: - default-ci-workflow-wrappers - - inject-passwords: - global: true - mask-password-params: true - job-template: name: 'ci-{component}-dispatcher-commit' diff --git a/build-on-push/platform_ci/platform_ci/jjb.py b/build-on-push/platform_ci/platform_ci/jjb.py index 8241cd7..fee0014 100644 --- a/build-on-push/platform_ci/platform_ci/jjb.py +++ b/build-on-push/platform_ci/platform_ci/jjb.py @@ -82,7 +82,7 @@ def get_job_as_xml(self, job): jjb_xml = subprocess.Popen(to_execute, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] - if not jjb_xml: + if not jjb_xml and os.getenv("JOB_BUILDER_PASS", None): jjb_user = os.environ["JOB_BUILDER_USER"] jjb_password = os.environ["JOB_BUILDER_PASS"] @@ -91,4 +91,11 @@ def get_job_as_xml(self, job): jjb_xml = subprocess.Popen(to_execute, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] + if not jjb_xml: + # This is for case job doesn't have credentials and update fail with config containing just url. + # It should pass without any config at all + # Only jobs, which really need credentials, have access to them. + to_execute = ["jenkins-jobs", "test", self.workdir, job.name] + jjb_xml = subprocess.Popen(to_execute, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] + return jjb_xml