当前位置: 首页>>代码示例>>Python>>正文


Python Jenkins.create_job方法代码示例

本文整理汇总了Python中pyjen.jenkins.Jenkins.create_job方法的典型用法代码示例。如果您正苦于以下问题:Python Jenkins.create_job方法的具体用法?Python Jenkins.create_job怎么用?Python Jenkins.create_job使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjen.jenkins.Jenkins的用法示例。


在下文中一共展示了Jenkins.create_job方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_build_blocker_functionality

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_build_blocker_functionality(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    job_name1 = "test_build_blocker_functionality1"
    jb1 = jk.create_job(job_name1, FreestyleJob)
    with clean_job(jb1):
        job_name2 = "test_build_blocker_functionality2"
        jb2 = jk.create_job(job_name2, FreestyleJob)
        with clean_job(jb2):
            expected_jobs = job_name2
            build_blocker = BuildBlockerProperty.instantiate(expected_jobs)
            jb1.quiet_period = 0
            jb1.add_property(build_blocker)

            # 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(job_name1).properties)

            build_step = ShellBuilder.instantiate("sleep 10")
            jb2.quiet_period = 0
            jb2.add_builder(build_step)
            async_assert(lambda: jb2.builders)
            queue2 = jb2.start_build()

            async_assert(lambda: not queue2.waiting)

            queue1 = jb1.start_build()
            assert job_name2 in queue1.reason

            queue2.build.abort()
            assert queue1.waiting is False
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:32,代码来源:test_build_blocker.py

示例2: test_multiple_upstream_jobs_recursive

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
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)
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:29,代码来源:test_job.py

示例3: test_create_multijob_job

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_create_multijob_job(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    expected_name = "test_create_multijob_job"
    jb = jk.create_job(expected_name, MultiJob)
    with clean_job(jb):
        assert jb is not None
        assert jb.name == expected_name
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:9,代码来源:test_multijob_job.py

示例4: test_never_run_condition

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_never_run_condition(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    expected_job_name = "test_never_run_condition"
    jb = jk.create_job(expected_job_name, FreestyleJob)
    with clean_job(jb):
        expected_output = "Here is my sample output..."
        shell_builder = ShellBuilder.instantiate("echo " + expected_output)
        condition = NeverRun.instantiate()
        conditional_builder = ConditionalBuilder.instantiate(condition, shell_builder)
        jb.add_builder(conditional_builder)

        # 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(expected_job_name).builders)

        builders = jk.find_job(expected_job_name).builders

        # Make sure the builder was correctly configured
        assert builders[0].condition is not None
        assert isinstance(builders[0].condition, NeverRun)
        assert builders[0].condition.get_friendly_name() == "never"

        # Finally, just to be sure our build actually did something relevant
        # we make sure the output from our shell command appears in the
        # build output for a build (ie: to ensure the conditional build step
        # actually ran)
        jb.start_build()
        async_assert(lambda: jb.last_build)

        assert expected_output not in jb.last_build.console_output
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:32,代码来源:test_conditional_builder.py

示例5: test_param_trigger

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_param_trigger(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    upstream_name = "test_param_trigger"
    jb = jk.create_job(upstream_name, FreestyleJob)
    with clean_job(jb):
        downstream_name = "sample_job"
        new_trigger = BuildTriggerConfig.instantiate([downstream_name])
        pub = ParameterizedBuildTrigger.instantiate([new_trigger])
        jb.add_publisher(pub)

        # 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], ParameterizedBuildTrigger)
        triggers = pubs[0].triggers
        assert isinstance(triggers, list)
        assert len(triggers) == 1
        names = triggers[0].job_names
        assert isinstance(names, list)
        assert len(names) == 1
        assert names[0] == downstream_name
        assert triggers[0].condition == "SUCCESS"
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:28,代码来源:test_param_build_trigger.py

示例6: test_trigger_with_current_build_params

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_trigger_with_current_build_params(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    upstream_name = "test_trigger_with_current_build_params"
    jb = jk.create_job(upstream_name, FreestyleJob)
    with clean_job(jb):
        downstream_name = "sample_job"
        new_trigger = BuildTriggerConfig.instantiate([downstream_name])
        cur_bld_params = CurrentBuildParams.instantiate()
        new_trigger.add_build_param(cur_bld_params)
        new_pub = ParameterizedBuildTrigger.instantiate([new_trigger])
        jb.add_publisher(new_pub)

        # 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 len(pubs) == 1
        cur_pub = pubs[0]
        assert len(cur_pub.triggers) == 1
        cur_trig = cur_pub.triggers[0]
        assert len(cur_trig.build_params) == 1
        cur_param_cfg = cur_trig.build_params[0]

        assert isinstance(cur_param_cfg, CurrentBuildParams)
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:27,代码来源:test_param_build_trigger.py

示例7: test_quiet_period

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_quiet_period(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    jb = jk.create_job("test_quiet_period", FreestyleJob)
    with clean_job(jb):
        jb.quiet_period = 0
        # first set our quiet period
        expected_duration = 10
        jb.quiet_period = expected_duration

        expected_output = "Testing my quiet period"
        failing_step = ShellBuilder.instantiate("echo " + expected_output)
        jb.add_builder(failing_step)
        async_assert(lambda: jb.builders)

        assert jb.quiet_period_enabled is True
        assert jb.quiet_period == expected_duration

        # Launch a build and time how long it takes to complete
        start = timeit.default_timer()
        jb.start_build()
        async_assert(lambda: jb.last_build, expected_duration + 5)
        duration = timeit.default_timer() - start
        assert duration >= expected_duration

        bld = jb.last_build
        assert expected_output in bld.console_output
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:28,代码来源:test_job.py

示例8: test_build_git_scm

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_build_git_scm(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    job_name = "test_build_git_scm"
    jb = jk.create_job(job_name, FreestyleJob)
    with clean_job(jb):
        jb.quiet_period = 0
        expected_url = "https://github.com/TheFriendlyCoder/pyjen.git"
        test_scm = GitSCM.instantiate(expected_url)
        jb.scm = test_scm

        async_assert(lambda: isinstance(jb.scm, GitSCM))

        # If the Git SCM was set up correctly, the job should check out the
        # source code for pyjen into the workspace when building. That being
        # the case there should be a setup.py script in the root folder. We
        # can therefore check to see if the SCM operation completed successfully
        # by looking for that file and setting a non-zero error code as part
        # of a shell builder operation
        shell_builder = ShellBuilder.instantiate("[ -f setup.py ]")
        jb.add_builder(shell_builder)

        # 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(job_name).builders)

        jb.start_build()
        async_assert(lambda: jb.last_good_build or jb.last_failed_build)

        assert jb.last_good_build is not None
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:31,代码来源:test_git_scm.py

示例9: test_add_artifact_deployer_publisher_entry

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_add_artifact_deployer_publisher_entry(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    job_name = "test_add_artifact_deployer_publisher_entry"
    jb = jk.create_job(job_name, FreestyleJob)
    with clean_job(jb):
        publisher = ArtifactDeployer.instantiate()
        jb.add_publisher(publisher)

        expected_regex = "*.txt"
        expected_path = "/bin/data"
        entry = ArtifactDeployerEntry.instantiate(expected_regex, expected_path)
        publisher.add_entry(entry)

        # 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(job_name).publishers)
        pubs = jk.find_job(job_name).publishers

        assert len(pubs) == 1
        cur_pub = pubs[0]
        assert isinstance(cur_pub, ArtifactDeployer)
        assert isinstance(cur_pub.entries, list)
        assert len(cur_pub.entries) == 1
        cur_entry = cur_pub.entries[0]
        assert isinstance(cur_entry, ArtifactDeployerEntry)
        assert cur_entry.includes == expected_regex
        assert cur_entry.remote == expected_path
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:29,代码来源:test_artifact_deployer.py

示例10: test_wait_for_idle

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_wait_for_idle(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    node = jk.nodes[0]
    expected_job_name = "test_wait_for_idle_job"
    jb = jk.create_job(expected_job_name, FreestyleJob)
    with clean_job(jb):
        jb.quiet_period = 0
        shell_builder = ShellBuilder.instantiate("sleep 2")
        jb.add_builder(shell_builder)

        # 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(expected_job_name).builders)

        # Trigger a build
        jb.start_build()

        # The 'last_build' reference becomes available as soon as the previously
        # triggered build exits the queue and starts running. So we wait for the
        # last build to become valid before checking the node activity
        async_assert(lambda: jb.last_build)

        assert node.is_idle is False
        assert node.wait_for_idle()
        assert node.is_idle
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:27,代码来源:test_node.py

示例11: test_add_conditional_builder

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_add_conditional_builder(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    expected_job_name = "test_add_conditional_builder"
    jb = jk.create_job(expected_job_name, FreestyleJob)
    with clean_job(jb):
        expected_output = "Here is my sample output..."
        expected_cmd = "echo " + expected_output
        shell_builder = ShellBuilder.instantiate(expected_cmd)
        condition = AlwaysRun.instantiate()
        conditional_builder = ConditionalBuilder.instantiate(condition, shell_builder)
        jb.add_builder(conditional_builder)

        # 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(expected_job_name).builders)

        builders = jk.find_job(expected_job_name).builders

        # Make sure the builder was successfully added and it's response
        # data can be parsed correctly
        assert isinstance(builders, list)
        assert len(builders) == 1
        assert isinstance(builders[0], ConditionalBuilder)
        assert builders[0].builder is not None
        assert isinstance(builders[0].builder, ShellBuilder)
        assert builders[0].builder.script == expected_cmd
        assert_elements_equal(builders[0].builder.node, shell_builder.node)
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:29,代码来源:test_conditional_builder.py

示例12: test_artifacts_archived

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_artifacts_archived(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    job_name = "test_artifacts_archived_job"
    jb = jk.create_job(job_name, FreestyleJob)
    with clean_job(jb):
        publisher = ArtifactArchiverPublisher.instantiate("*.txt")
        jb.add_publisher(publisher)

        # Wait until our publisher config get's applied
        async_assert(lambda: jk.find_job(job_name).publishers)

        expected_file = "test_artifacts_archived_job.txt"
        shell_builder = ShellBuilder.instantiate("echo hello > " + expected_file)
        jb.add_builder(shell_builder)

        # Wait until our builder get's applied
        async_assert(lambda: jk.find_job(job_name).builders)

        # Next, trigger a build
        jb.start_build()
        async_assert(lambda: len(jb.all_builds) == 1)

        # finally, make sure the list or archived artifacts looks correct
        bld = jb.all_builds[0]
        results = bld.artifact_urls

        assert isinstance(results, list)
        assert len(results) == 1
        assert expected_file in results[0]
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:31,代码来源:test_artifact_archiver.py

示例13: test_always_run_condition

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_always_run_condition(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    expected_job_name = "test_always_run_condition"
    jb = jk.create_job(expected_job_name, FreestyleJob)
    with clean_job(jb):
        expected_output = "Here is my sample output..."
        expected_cmd = "echo " + expected_output
        shell_builder = ShellBuilder.instantiate(expected_cmd)
        condition = AlwaysRun.instantiate()
        conditional_builder = ConditionalBuilder.instantiate(condition, shell_builder)
        jb.add_builder(conditional_builder)

        # Wait until our job config has been applied successfully
        async_assert(lambda: jk.find_job(expected_job_name).builders)

        # Make sure the condition is loaded correctly
        builders = jk.find_job(expected_job_name).builders
        assert isinstance(builders[0].condition, AlwaysRun)
        assert  builders[0].condition.get_friendly_name() == "always"

        # Run a build and make sure the build operation actually executed
        jb.start_build()
        async_assert(lambda: jb.last_build)

        assert expected_output in jb.last_build.console_output
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:27,代码来源:test_conditional_builder.py

示例14: test_enable

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_enable(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    jb = jk.create_job("test_enable", FreestyleJob)
    with clean_job(jb):
        jb.disable()
        jb.enable()
        assert not jb.is_disabled
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:9,代码来源:test_job.py

示例15: test_delete_job

# 需要导入模块: from pyjen.jenkins import Jenkins [as 别名]
# 或者: from pyjen.jenkins.Jenkins import create_job [as 别名]
def test_delete_job(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    expected_name = "test_delete_job"
    jb = jk.create_job(expected_name, FreestyleJob)
    jb.delete()
    res = jk.find_job(expected_name)
    assert res is None
开发者ID:TheFriendlyCoder,项目名称:pyjen,代码行数:9,代码来源:test_job.py


注:本文中的pyjen.jenkins.Jenkins.create_job方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。