Esempio n. 1
0
def test_multiple_upstream_jobs_recursive(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    parent_job_name = "test_multiple_upstream_jobs_recursive1"
    jb = jk.create_job(parent_job_name, FreestyleJob)
    with clean_job(jb):
        expected_name1 = "test_multiple_upstream_jobs_recursive2"
        jb2 = jk.create_job(expected_name1, FreestyleJob)
        with clean_job(jb2):
            expected_name2 = "test_multiple_upstream_jobs_recursive3"
            jb3 = jk.create_job(expected_name2, FreestyleJob)
            with clean_job(jb3):
                publisher1 = BuildTriggerPublisher.instantiate([expected_name1])
                jb.add_publisher(publisher1)

                publisher2 = BuildTriggerPublisher.instantiate([expected_name2])
                jb2.add_publisher(publisher2)

                async_assert(lambda: len(jb3.all_upstream_jobs) == 2)
                res = jb3.all_upstream_jobs

                all_names = [parent_job_name, expected_name1]
                assert isinstance(res, list)
                assert len(res) == 2
                assert res[0].name in all_names
                assert res[1].name in all_names
                assert isinstance(res[0], FreestyleJob)
                assert isinstance(res[1], FreestyleJob)
Esempio n. 2
0
def test_multiple_upstream_jobs_recursive(jenkins_env):
    jk = Jenkins(jenkins_env["url"],
                 (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    parent_job_name = "test_multiple_upstream_jobs_recursive1"
    jb = jk.create_job(parent_job_name, FreestyleJob)
    with clean_job(jb):
        expected_name1 = "test_multiple_upstream_jobs_recursive2"
        jb2 = jk.create_job(expected_name1, FreestyleJob)
        with clean_job(jb2):
            expected_name2 = "test_multiple_upstream_jobs_recursive3"
            jb3 = jk.create_job(expected_name2, FreestyleJob)
            with clean_job(jb3):
                publisher1 = BuildTriggerPublisher.create([expected_name1])
                jb.add_publisher(publisher1)

                publisher2 = BuildTriggerPublisher.create([expected_name2])
                jb2.add_publisher(publisher2)

                async_assert(lambda: len(jb3.all_upstream_jobs) == 2)
                res = jb3.all_upstream_jobs

                all_names = [parent_job_name, expected_name1]
                assert isinstance(res, list)
                assert len(res) == 2
                assert res[0].name in all_names
                assert res[1].name in all_names
                assert isinstance(res[0], FreestyleJob)
                assert isinstance(res[1], FreestyleJob)
def test_one_downstream_job(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    jb = jk.create_job("test_one_downstream_job1", FreestyleJob)
    with clean_job(jb):
        expected_name = "test_one_downstream_job2"
        jb2 = jk.create_job(expected_name, FreestyleJob)
        with clean_job(jb2):
            publisher = BuildTriggerPublisher.instantiate([expected_name])
            jb.add_publisher(publisher)

            async_assert(lambda: jb.downstream_jobs)
            res = jb.downstream_jobs

            assert isinstance(res, list)
            assert len(res) == 1
            assert res[0].name == expected_name
Esempio n. 4
0
def test_one_upstream_job(jenkins_env):
    jk = Jenkins(jenkins_env["url"],
                 (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    parent_job_name = "test_one_upstream_job1"
    jb = jk.create_job(parent_job_name, FreestyleJob)
    with clean_job(jb):
        child_job_name = "test_one_upstream_job2"
        jb2 = jk.create_job(child_job_name, FreestyleJob)
        with clean_job(jb2):
            publisher = BuildTriggerPublisher.create([child_job_name])
            jb.add_publisher(publisher)

            async_assert(lambda: jb2.upstream_jobs)
            res = jb2.upstream_jobs

            assert isinstance(res, list)
            assert len(res) == 1
            assert res[0].name == parent_job_name
def test_multiple_downstream_jobs(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    jb = jk.create_job("test_multiple_downstream_jobs1", FreestyleJob)
    with clean_job(jb):
        expected_name1 = "test_multiple_downstream_jobs2"
        jb2 = jk.create_job(expected_name1, FreestyleJob)
        with clean_job(jb2):
            expected_name2 = "test_multiple_downstream_jobs3"
            jb3 = jk.create_job(expected_name2, FreestyleJob)
            with clean_job(jb3):
                all_names = [expected_name1,expected_name2]
                publisher = BuildTriggerPublisher.instantiate(all_names)
                jb.add_publisher(publisher)

                async_assert(lambda: jb.downstream_jobs)
                res = jb.downstream_jobs

                assert isinstance(res, list)
                assert len(res) == 2
                assert res[0].name in all_names
                assert res[1].name in all_names
def test_add_build_trigger_publisher(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    upstream_name = "test_add_build_trigger_publisher1"
    jb = jk.create_job(upstream_name, FreestyleJob)
    with clean_job(jb):
        downstream_name = "test_add_build_trigger_publisher2"
        jb2 = jk.create_job(downstream_name, FreestyleJob)
        with clean_job(jb2):
            publisher = BuildTriggerPublisher.instantiate([downstream_name])
            jb.add_publisher(publisher)

            # Get a fresh copy of our job to ensure we have an up to date
            # copy of the config.xml for the job
            async_assert(lambda: jk.find_job(upstream_name).publishers)
            pubs = jk.find_job(upstream_name).publishers

            assert isinstance(pubs, list)
            assert len(pubs) == 1
            assert isinstance(pubs[0], BuildTriggerPublisher)
            names = pubs[0].job_names
            assert isinstance(names, list)
            assert len(names) == 1
            assert names[0] == downstream_name