Revert "allow disabled to remain the last setting"

This reverts commit 8bffa4d520.
8bffa4d520 introduced a bug where new jobs
without a `disabled` value configured in their source would fail to be
created on Jenkins.
Reverting 8bffa4d520 for now while the bug
is addressed and sufficient test cases created to catch such a
regression.

Change-Id: Ia8adc1f8394b6a745e8bbc7038c85958c56fd11b
This commit is contained in:
Ankush Pathak 2024-07-10 09:19:19 -05:00
parent 78fef52437
commit f2f3325f5a
2 changed files with 0 additions and 16 deletions

View File

@ -350,18 +350,9 @@ class JenkinsManager(object):
@concurrent
def parallel_update_job(self, job):
self.fix_disabled(job)
self.update_job(job.name, job.output().decode("utf-8"))
return (job.name, job.md5())
def fix_disabled(self, job):
el = job.xml.find("./disabled")
if el is not None:
return
info = self.jenkins.get_job_info(job.name)
disabled = info["disabled"]
XML.SubElement(job.xml, "disabled").text = str(disabled).lower()
################
# View related #
################

View File

@ -29,7 +29,6 @@ def test_update_jobs(mocker, fixtures_dir, default_config_file, execute_jenkins_
"""
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.job_exists")
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.get_all_jobs")
mocker.patch("jenkins_jobs.builder.JenkinsManager.fix_disabled")
reconfig_job = mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.reconfig_job")
path = fixtures_dir / "cmd-002.yaml"
@ -54,7 +53,6 @@ def test_update_jobs_enabled_only(
"""
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.job_exists")
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.get_all_jobs")
mocker.patch("jenkins_jobs.builder.JenkinsManager.fix_disabled")
reconfig_job = mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.reconfig_job")
path = fixtures_dir / "cmd-002.yaml"
@ -79,7 +77,6 @@ def test_update_jobs_decode_job_output(
mocker.patch("jenkins_jobs.builder.JenkinsManager.is_job", return_value=True)
mocker.patch("jenkins_jobs.builder.JenkinsManager.get_jobs")
mocker.patch("jenkins_jobs.builder.JenkinsManager.get_job_md5")
mocker.patch("jenkins_jobs.builder.JenkinsManager.fix_disabled")
update_job_mock = mocker.patch("jenkins_jobs.builder.JenkinsManager.update_job")
# don't care about the value returned here
@ -107,7 +104,6 @@ def test_update_jobs_and_delete_old(
True.
"""
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.job_exists")
mocker.patch("jenkins_jobs.builder.JenkinsManager.fix_disabled")
jenkins_get_all_jobs = mocker.patch(
"jenkins_jobs.builder.jenkins.Jenkins.get_all_jobs"
)
@ -245,7 +241,6 @@ def test_update_jobs_and_views(
"""
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.job_exists")
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.get_all_jobs")
mocker.patch("jenkins_jobs.builder.JenkinsManager.fix_disabled")
reconfig_job = mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.reconfig_job")
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.view_exists")
@ -282,7 +277,6 @@ def test_update_jobs_only(
"""
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.job_exists")
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.get_all_jobs")
mocker.patch("jenkins_jobs.builder.JenkinsManager.fix_disabled")
reconfig_job = mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.reconfig_job")
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.view_exists")
@ -371,7 +365,6 @@ def test_update_views_and_delete_old_jobs_only(
No views should be deleted or updated.
"""
mocker.patch("jenkins_jobs.builder.jenkins.Jenkins.job_exists")
mocker.patch("jenkins_jobs.builder.JenkinsManager.fix_disabled")
jenkins_get_all_jobs = mocker.patch(
"jenkins_jobs.builder.jenkins.Jenkins.get_all_jobs"
)