Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

operators-iib: add condition to trigger config jobs only #160

Merged
merged 8 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 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:
rnetser marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -208,6 +205,10 @@ def get_iib_data_from_file(config_data):
return {}


def get_jobs_name_from_config(ci_jobs):
return [job["name"] for jobs in ci_jobs.values() if jobs for job in jobs]
chetna14manku marked this conversation as resolved.
Show resolved Hide resolved


def verify_s3_or_local_file(
s3_bucket_operators_latest_iib_path,
user_local_operators_latest_iib_filepath,
Expand Down Expand Up @@ -260,27 +261,33 @@ 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)
ci_jobs_name = get_jobs_name_from_config(ci_jobs=ci_jobs)

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 ci_jobs_name:
chetna14manku marked this conversation as resolved.
Show resolved Hide resolved
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