<buildWrappers/>
</project>
"""
+
+JOB_WITH_ARTIFACTS = """
+<?xml version='1.0' encoding='UTF-8'?>
+<project>
+ <actions/>
+ <description>Ping a load of stuff for about 10s</description>
+ <keepDependencies>false</keepDependencies>
+ <properties/>
+ <scm class="hudson.scm.NullSCM"/>
+ <canRoam>true</canRoam>
+ <disabled>false</disabled>
+ <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
+ <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
+ <triggers class="vector"/>
+ <concurrentBuild>false</concurrentBuild>
+ <builders>
+ <hudson.tasks.Shell>
+ <command>ping -c 5 localhost | tee out.txt</command>
+ </hudson.tasks.Shell>
+ </builders>
+ <publishers>
+ <hudson.tasks.ArtifactArchiver>
+ <artifacts>*.txt</artifacts>
+ <latestOnly>false</latestOnly>
+ </hudson.tasks.ArtifactArchiver>
+ <hudson.tasks.Fingerprinter>
+ <targets></targets>
+ <recordBuildArtifacts>true</recordBuildArtifacts>
+ </hudson.tasks.Fingerprinter>
+ </publishers>
+ <buildWrappers/>
+</project>""".strip()
\ No newline at end of file
import shutil
import tempfile
import unittest
-from jenkinsapi_tests.test_utils.random_strings import random_string
-from jenkinsapi_tests.systests.base import BaseSystemTest
-PINGER_JOB_CONFIG = """
-<?xml version='1.0' encoding='UTF-8'?>
-<project>
- <actions/>
- <description>Ping a load of stuff for about 10s</description>
- <keepDependencies>false</keepDependencies>
- <properties/>
- <scm class="hudson.scm.NullSCM"/>
- <canRoam>true</canRoam>
- <disabled>false</disabled>
- <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
- <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
- <triggers class="vector"/>
- <concurrentBuild>false</concurrentBuild>
- <builders>
- <hudson.tasks.Shell>
- <command>ping -c 5 localhost | tee out.txt</command>
- </hudson.tasks.Shell>
- </builders>
- <publishers>
- <hudson.tasks.ArtifactArchiver>
- <artifacts>*.txt</artifacts>
- <latestOnly>false</latestOnly>
- </hudson.tasks.ArtifactArchiver>
- <hudson.tasks.Fingerprinter>
- <targets></targets>
- <recordBuildArtifacts>true</recordBuildArtifacts>
- </hudson.tasks.Fingerprinter>
- </publishers>
- <buildWrappers/>
-</project>""".strip()
+from jenkinsapi_tests.systests.base import BaseSystemTest
+from jenkinsapi_tests.systests.job_configs import JOB_WITH_ARTIFACTS
+from jenkinsapi_tests.test_utils.random_strings import random_string
class TestPingerJob(BaseSystemTest):
def test_invoke_job(self):
job_name = 'create_%s' % random_string()
- job = self.jenkins.create_job(job_name, PINGER_JOB_CONFIG)
+ job = self.jenkins.create_job(job_name, JOB_WITH_ARTIFACTS)
job.invoke(block=True)
b = job.get_last_build()
tempDir = tempfile.mkdtemp()
try:
- tf = tempfile.NamedTemporaryFile(mode='wb')
artifact.save_to_dir(tempDir)
readBackText = open(os.path.join(tempDir, artifact.filename), 'rb').read().strip()
self.assertTrue(readBackText.startswith('PING localhost'))
finally:
shutil.rmtree(tempDir)
-
- # TODO: Actually verify the download
-
-
if __name__ == '__main__':
unittest.main()