Beispiel #1
0
def test_label_create_job(create_slave):
    test_job_name = get_test_job_name()
    jenkins.create_job(config.SERVICE_NAME, test_job_name, "echo \"test command\";", 1, create_slave)
    job = jenkins.get_job(config.SERVICE_NAME, test_job_name)

    assert test_job_name == job['name']
    wait_until_job_run(config.SERVICE_NAME, test_job_name)
Beispiel #2
0
    def jenkins_format_xml(self, xml_job: XmlJob):
        """
        bounces job config through jenkins to get the formatting right
        unused, deprecated
        """
        jenkins = self.jenkins
        _xml: xml.etree.ElementTree.Element = xml_job.xml

        if not _xml.find("./disabled"):
            d = xml.etree.ElementTree.Element("disabled")
            d.text = "false"
            _xml.append(d)
        disabled_job = _xml.find("./disabled").text == "true"

        rand_suffix = "".join(
            random.choice(string.hexdigits) for _ in range(10))
        tmp_name = f"zz_jjm_tmp_{xml_job.name}_{rand_suffix}"
        tmp_xml = xml_job.xml
        tmp_xml.find("./disabled").text = "true"
        tmp_xml_str = xml.etree.ElementTree.tostring(tmp_xml,
                                                     encoding="unicode")
        log.info("creating %s", tmp_name)
        jenkins.create_job(tmp_name, tmp_xml_str)
        formatted_xml = jenkins.get_job_config(tmp_name)
        log.info("removing %s", tmp_name)
        jenkins.delete_job(tmp_name)
        if not disabled_job:
            formatted_xml = formatted_xml.replace(
                "<disabled>true</disabled>", "<disabled>false</disabled>")
        return formatted_xml
def test_create_job():
    test_job_name = get_test_job_name()
    jenkins.create_job(config.SERVICE_NAME, test_job_name,
                       "echo \"test command\";", 5)
    job = jenkins.get_job(config.SERVICE_NAME, test_job_name)

    assert test_job_name == job['name']
Beispiel #4
0
def test_install_custom_name():
    svc_name = 'jenkins-custom'
    test_job_name = get_test_job_name()

    sdk_install.uninstall(config.PACKAGE_NAME, svc_name)

    try:
        jenkins.install(svc_name)
        jenkins.create_job(svc_name, test_job_name)
        job = jenkins.get_job(svc_name, test_job_name)
        assert test_job_name == job['name']
    finally:
        sdk_install.uninstall(config.PACKAGE_NAME, svc_name)
def test_install_custom_name():
    svc_name = 'jenkins-custom'
    test_job_name = get_test_job_name()

    sdk_install.uninstall(config.PACKAGE_NAME, svc_name)

    try:
        client = shakedown.marathon.create_client()
        jenkins.install(svc_name, client)
        jenkins.create_job(svc_name, test_job_name)
        job = jenkins.get_job(svc_name, test_job_name)
        assert test_job_name == job['name']
    finally:
        sdk_install.uninstall(config.PACKAGE_NAME, svc_name)