Skip to content

Commit

Permalink
operators-iib: add condition to trigger config jobs only (#160)
Browse files Browse the repository at this point in the history
* trigger config jobs only

* update get_new_iib func

* update get_jobs and z-stream config

* update get jobs name

* update if condition to check job name
  • Loading branch information
chetna14manku authored May 23, 2024
1 parent 0e78d5f commit e1d5420
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
42 changes: 22 additions & 20 deletions ci_jobs_trigger/libs/operators_iib_trigger/iib_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,8 @@ def get_new_iib(config_data, logger):
new_trigger_data = False
data_from_file = get_iib_data_from_file(config_data=config_data)
new_data = copy.deepcopy(data_from_file)
if (ci_jobs := config_data.get("ci_jobs", {})) is None:
logger.error(f"{LOG_PREFIX} No ci_jobs found in config")
return {}

for _ocp_version, _jobs_data in ci_jobs.items():
for _ocp_version, _jobs_data in config_data.get("ci_jobs", {}).items():
if _jobs_data:
for _ci_job in _jobs_data:
job_name = _ci_job["name"]
Expand Down Expand Up @@ -260,27 +257,32 @@ def fetch_update_iib_and_trigger_jobs(logger, tmp_dir, config_dict=None):
):
return False

if (ci_jobs := config_data.get("ci_jobs", {})) is None:
logger.error(f"{LOG_PREFIX} No ci_jobs found in config")
return {}

trigger_dict = get_new_iib(config_data=config_data, logger=logger)

failed_triggered_jobs = {}
for _, _job_data in trigger_dict.items():
for _job_name, _job_dict in _job_data.items():
operators = _job_dict["operators"]
if any([_value["new-iib"] for _value in operators.values()]):
try:
trigger_ci_job(
job=_job_name,
product=", ".join(operators.keys()),
_type="operator",
trigger_dict=trigger_dict,
ci=_job_dict["ci"],
logger=logger,
config_data=config_data,
operator_iib=True,
)
except AddonsWebhookTriggerError:
failed_triggered_jobs.setdefault(_job_dict["ci"], []).append(_job_name)
continue
if _job_name in [job["name"] for jobs in ci_jobs.values() if jobs for job in jobs]:
operators = _job_dict["operators"]
if any([_value["new-iib"] for _value in operators.values()]):
try:
trigger_ci_job(
job=_job_name,
product=", ".join(operators.keys()),
_type="operator",
trigger_dict=trigger_dict,
ci=_job_dict["ci"],
logger=logger,
config_data=config_data,
operator_iib=True,
)
except AddonsWebhookTriggerError:
failed_triggered_jobs.setdefault(_job_dict["ci"], []).append(_job_name)
continue
return failed_triggered_jobs


Expand Down
1 change: 0 additions & 1 deletion config-examples/ci-iib-jobs-trigger-config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ci_jobs:
<product name 2>: <operator name 2>

<openshift version 2>:
jobs:
- name: <jenkins job name>
ci: jenkins
products:
Expand Down

0 comments on commit e1d5420

Please sign in to comment.