diff --git a/tests/triggers/job_fixtures/zuul-trigger-both.xml b/tests/triggers/job_fixtures/zuul-trigger-both.xml new file mode 100644 index 000000000..4c92f43dd --- /dev/null +++ b/tests/triggers/job_fixtures/zuul-trigger-both.xml @@ -0,0 +1,158 @@ + + + + <!-- Managed by Jenkins Job Builder --> + false + false + false + false + true + + + + + ZUUL_UUID + Zuul provided key to link builds with Gerrit events + + false + + + UUID + Zuul provided key to link builds with Gerrit events (deprecated use ZUUL_UUID instead) + + false + + + ZUUL_PIPELINE + Zuul pipeline triggering this job + + false + + + ZUUL_URL + URL of Zuul's git repos accessible to workers + + false + + + ZUUL_PROJECT + Branch name of triggering project + + false + + + ZUUL_BRANCH + Branch name of triggering change + + false + + + ZUUL_CHANGES + List of dependent changes to merge + + false + + + ZUUL_REF + Reference for the merged commit(s) to use + + false + + + ZUUL_COMMIT + The commit SHA1 at the head of ZUUL_REF + + false + + + ZUUL_CHANGE_IDS + List of included changes + + false + + + ZUUL_CHANGE + ID of triggering change + + false + + + ZUUL_PATCHSET + Patchset of triggering change + + false + + + ZUUL_VOTING + Zuul considered this job voting or not + + false + + + ZUUL_UUID + Zuul provided key to link builds with Gerrit events + + false + + + UUID + Zuul provided key to link builds with Gerrit events (deprecated use ZUUL_UUID instead) + + false + + + ZUUL_PIPELINE + Zuul pipeline triggering this job + + false + + + ZUUL_URL + URL of Zuul's git repos accessible to workers + + false + + + ZUUL_PROJECT + Branch name of triggering project + + false + + + ZUUL_REF + Name of updated reference triggering this job + + false + + + ZUUL_REFNAME + Name of updated reference triggering this job + + false + + + ZUUL_OLDREV + Old SHA at this reference + + false + + + ZUUL_NEWREV + New SHA at this reference + + false + + + ZUUL_SHORT_NEWREV + Shortened new SHA at this reference + + false + + + + + + + + + diff --git a/tests/triggers/job_fixtures/zuul-trigger-both.yaml b/tests/triggers/job_fixtures/zuul-trigger-both.yaml new file mode 100644 index 000000000..b9726e3b4 --- /dev/null +++ b/tests/triggers/job_fixtures/zuul-trigger-both.yaml @@ -0,0 +1,10 @@ +- job-template: + name: sample-job + triggers: + - zuul + - zuul-post + +- project: + name: sample-project + jobs: + - sample-job diff --git a/tests/triggers/job_fixtures/zuul-trigger-post.xml b/tests/triggers/job_fixtures/zuul-trigger-post.xml new file mode 100644 index 000000000..ca1efa259 --- /dev/null +++ b/tests/triggers/job_fixtures/zuul-trigger-post.xml @@ -0,0 +1,80 @@ + + + + <!-- Managed by Jenkins Job Builder --> + false + false + false + false + true + + + + + ZUUL_UUID + Zuul provided key to link builds with Gerrit events + + false + + + UUID + Zuul provided key to link builds with Gerrit events (deprecated use ZUUL_UUID instead) + + false + + + ZUUL_PIPELINE + Zuul pipeline triggering this job + + false + + + ZUUL_URL + URL of Zuul's git repos accessible to workers + + false + + + ZUUL_PROJECT + Branch name of triggering project + + false + + + ZUUL_REF + Name of updated reference triggering this job + + false + + + ZUUL_REFNAME + Name of updated reference triggering this job + + false + + + ZUUL_OLDREV + Old SHA at this reference + + false + + + ZUUL_NEWREV + New SHA at this reference + + false + + + ZUUL_SHORT_NEWREV + Shortened new SHA at this reference + + false + + + + + + + + + diff --git a/tests/triggers/job_fixtures/zuul-trigger-post.yaml b/tests/triggers/job_fixtures/zuul-trigger-post.yaml new file mode 100644 index 000000000..ebdf6c92e --- /dev/null +++ b/tests/triggers/job_fixtures/zuul-trigger-post.yaml @@ -0,0 +1,9 @@ +- job-template: + name: sample-job + triggers: + - zuul-post + +- project: + name: sample-project + jobs: + - sample-job diff --git a/tests/triggers/job_fixtures/zuul-trigger.xml b/tests/triggers/job_fixtures/zuul-trigger.xml new file mode 100644 index 000000000..49868fec4 --- /dev/null +++ b/tests/triggers/job_fixtures/zuul-trigger.xml @@ -0,0 +1,98 @@ + + + + <!-- Managed by Jenkins Job Builder --> + false + false + false + false + true + + + + + ZUUL_UUID + Zuul provided key to link builds with Gerrit events + + false + + + UUID + Zuul provided key to link builds with Gerrit events (deprecated use ZUUL_UUID instead) + + false + + + ZUUL_PIPELINE + Zuul pipeline triggering this job + + false + + + ZUUL_URL + URL of Zuul's git repos accessible to workers + + false + + + ZUUL_PROJECT + Branch name of triggering project + + false + + + ZUUL_BRANCH + Branch name of triggering change + + false + + + ZUUL_CHANGES + List of dependent changes to merge + + false + + + ZUUL_REF + Reference for the merged commit(s) to use + + false + + + ZUUL_COMMIT + The commit SHA1 at the head of ZUUL_REF + + false + + + ZUUL_CHANGE_IDS + List of included changes + + false + + + ZUUL_CHANGE + ID of triggering change + + false + + + ZUUL_PATCHSET + Patchset of triggering change + + false + + + ZUUL_VOTING + Zuul considered this job voting or not + + false + + + + + + + + + diff --git a/tests/triggers/job_fixtures/zuul-trigger.yaml b/tests/triggers/job_fixtures/zuul-trigger.yaml new file mode 100644 index 000000000..cddf7da7f --- /dev/null +++ b/tests/triggers/job_fixtures/zuul-trigger.yaml @@ -0,0 +1,9 @@ +- job-template: + name: sample-job + triggers: + - zuul + +- project: + name: sample-project + jobs: + - sample-job diff --git a/tests/triggers/test_job_triggers.py b/tests/triggers/test_job_triggers.py new file mode 100644 index 000000000..977bd6042 --- /dev/null +++ b/tests/triggers/test_job_triggers.py @@ -0,0 +1,21 @@ +from operator import attrgetter +from pathlib import Path + +import pytest + +from tests.enum_scenarios import scenario_list + + +fixtures_dir = Path(__file__).parent / "job_fixtures" + + +@pytest.fixture( + params=scenario_list(fixtures_dir), + ids=attrgetter("name"), +) +def scenario(request): + return request.param + + +def test_job(check_job): + check_job()