예제 #1
0
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.create(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.create("[ -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
예제 #2
0
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
예제 #3
0
파일: conftest.py 프로젝트: kieranlea/pyjen
def test_builds_with_git(request, test_job):
    """Helper fixture that creates a job with a sample build with Git sources for testing"""
    expected_url = "https://github.com/TheFriendlyCoder/pyjen.git"
    test_scm = GitSCM.instantiate(expected_url)
    request.cls.job.scm = test_scm

    request.cls.job.quiet_period = 0
    async_assert(lambda: isinstance(request.cls.job.scm, GitSCM))

    request.cls.job.start_build()
    async_assert(lambda: request.cls.job.last_good_build is not None)
예제 #4
0
def test_builds_with_git(request, test_job):
    """Helper fixture that creates a job with a sample build with Git sources for testing"""
    expected_url = "https://github.com/TheFriendlyCoder/pyjen.git"
    test_scm = GitSCM.instantiate(expected_url)
    request.cls.job.scm = test_scm

    request.cls.job.quiet_period = 0
    async_assert(lambda: isinstance(request.cls.job.scm, GitSCM))

    request.cls.job.start_build()
    async_assert(lambda: request.cls.job.last_good_build is not None)
예제 #5
0
def test_git_scm_pipeline_job(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    jb = jk.create_job("test_git_scm_pipeline_job", PipelineJob)
    with clean_job(jb):
        expected_url = "*****@*****.**"
        scm = GitSCM.instantiate(expected_url)
        jb.scm_definition(scm)

        assert jb.script == ""
        result = jb.scm
        assert result is not None
        assert isinstance(result, GitSCM)
        assert result.url == expected_url
        assert jb.script == ""
예제 #6
0
def test_add_git_scm(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    job_name = "test_add_git_scm"
    jb = jk.create_job(job_name, FreestyleJob)
    with clean_job(jb):
        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))

        jb2 = jk.find_job(job_name)

        result = jb2.scm
        assert result is not None
        assert isinstance(result, GitSCM)
예제 #7
0
def test_overwrite_definition(jenkins_env):
    jk = Jenkins(jenkins_env["url"], (jenkins_env["admin_user"], jenkins_env["admin_token"]))
    jb = jk.create_job("test_overwrite_definition", PipelineJob)
    with clean_job(jb):
        expected_url = "*****@*****.**"
        scm = GitSCM.instantiate(expected_url)
        jb.scm_definition(scm)

        jb.quiet_period = 0
        expected_output = "hello"
        expected_cmd = 'echo "{}"'.format(expected_output)
        jb.script_definition(expected_cmd)
        jb.start_build()

        async_assert(lambda: jb.last_good_build)
        assert jb.script == expected_cmd
        assert jb.scm is None
        assert expected_output in jb.last_build.console_output