Skip to content

Commit 3fa8e51

Browse files
authored
Release 0.1.1 (#4)
Release 0.1.1
1 parent 00837b1 commit 3fa8e51

File tree

13 files changed

+263
-60
lines changed

13 files changed

+263
-60
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ dist/
1515
downloads/
1616
eggs/
1717
.eggs/
18-
lib/
1918
lib64/
2019
parts/
2120
sdist/
@@ -101,3 +100,5 @@ ENV/
101100
.mypy_cache/
102101

103102
.pre-commit-config.yaml
103+
Pipfile
104+

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,34 @@ Introduction
77
------------
88

99
JenkinsLibrary is a Robot Framework test
10-
library which helps you to involve Jenkins in your tests.
11-
10+
library which helps you to involve Jenkins in your tests.
1211

1312
Installation
1413
------------
1514

1615
Just run:
1716

1817
pip install robotframework-jenkins
18+
19+
Usage
20+
------------
21+
22+
You need to import Jenkins library:
23+
24+
*** Settings ***
25+
Library JenkinsLibrary
26+
Then, you need to initialize Jenkins server with keyword:
27+
28+
Set Jenkins Server url=http://example.com:8080 username=admin password=admin
29+
30+
Example
31+
------------
32+
*** Settings ***
33+
Library JenkinsLibrary
34+
35+
*** Test Cases ***
36+
Jenkins Create And Run Job
37+
[Setup] Set Jenkins Server url=http://example.com:8080 username=admin password=admin
38+
Create Jenkins Job test_job
39+
Start Jenkins Job test_job
40+

atest/__init__.robot

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ Suite Setup Global Setup
44

55
*** Variables ***
66
${url} http://127.0.0.1:8080
7+
${templates_dir} templates
8+
${job_parameterized_scratch} job_parameterized_scratch.xml
9+
&{job_parameterized_scratch_parameters} param_string=expected_string param_bool=False
10+
${test_job_name} test_job
11+
${second_test_job_name} blablabla_job
12+
713

814
*** Keywords ***
915
Wait For Container
@@ -12,4 +18,9 @@ Wait For Container
1218

1319
Global Setup
1420
Set Global Variable ${jenkins_address} ${url}
21+
Set Global Variable ${templates_dir} atest/${templates_dir}
22+
Set Global Variable ${job_parameterized_scratch} ${job_parameterized_scratch}
23+
Set Global Variable ${test_job_name} ${test_job_name}
24+
Set Global Variable ${second_test_job_name} ${second_test_job_name}
25+
Set Global Variable ${job_parameterized_scratch_parameters} &{job_parameterized_scratch_parameters}
1526
Wait For Container

atest/basic.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*** Settings ***
22
Library JenkinsLibrary
3+
Resource lib/jenkins_keywords.robot
34

45
*** Test Cases ***
56
Keyword Without Init

atest/builds.robot

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
*** Settings ***
22
Library JenkinsLibrary
3+
Resource lib/jenkins_keywords.robot
34
Suite Setup Set Jenkins Server url=${jenkins_address} username=admin password=admin
45

5-
*** Variables ***
6-
${test_job_name} test_job
7-
86
*** Test Cases ***
97
Get Builds (inexistent job)
108
[Tags] job build
119
Run Keyword And Expect Error There is no specified job in Jenkins: ${test_job_name}\
1210
... Get Jenkins Job Builds ${test_job_name}
1311

1412
Get Builds (existent jobs, multiple builds)
15-
[Tags] job build
16-
[Setup] Create Job And Run Multiple Builds
13+
[Setup] Create Job And Run Multiple Builds ${test_job_name} count=3
1714
[Teardown] Delete Jenkins Job ${test_job_name}
1815
${builds} = Get Jenkins Job Builds ${test_job_name}
1916
Should Be True ${builds}
17+
Log ${builds}
2018
Should Be Equal As Integers 1 ${builds['builds'][2]['number']}
2119
Should Be Equal As Integers 2 ${builds['builds'][1]['number']}
2220
Should Be Equal As Integers 3 ${builds['builds'][0]['number']}
@@ -29,9 +27,14 @@ Get Builds (existent jobs, no builds)
2927
Should Not Be True ${builds['lastBuild']}
3028
Should Be Equal As Integers 1 ${builds['nextBuildNumber']}
3129

32-
*** Keywords ***
33-
Create Job And Run Multiple Builds
34-
Create Jenkins Job ${test_job_name}
35-
Start Jenkins Job ${test_job_name}
36-
Start Jenkins Job ${test_job_name}
37-
Start Jenkins Job ${test_job_name}
30+
Get Next Build Number
31+
[Tags] job build
32+
[Setup] Create Jenkins Job ${test_job_name}
33+
[Teardown] Delete Jenkins Job ${test_job_name}
34+
${random_int} = Evaluate random.randint(2, 10) modules=random
35+
:FOR ${run} IN RANGE ${random_int}
36+
\ ${next_build_before} = Get Next Build Number ${test_job_name}
37+
\ Should Be Equal As Integers ${run + 1} ${next_build_before}
38+
\ Start Jenkins Job ${test_job_name}
39+
\ ${next_build_after} = Get Next Build Number ${test_job_name}
40+
\ Should Be Equal As Integers ${run + 2} ${next_build_after}

atest/execute.robot

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
*** Settings ***
22
Library Collections
33
Library JenkinsLibrary
4+
Resource lib/jenkins_keywords.robot
45
Suite Setup Set Jenkins Server url=${jenkins_address} username=admin password=admin
56

6-
*** Variables ***
7-
${test_job_name} test_job
8-
97
*** Test Cases ***
108
Wrong Params Type
119
[Tags] execute
@@ -14,16 +12,41 @@ Wrong Params Type
1412
Run Keyword And Expect Error Params must be a dictionary, not *\
1513
... Start Jenkins Job ${test_job_name} test_string
1614

17-
Run Existent Job Without Params
15+
Run Inexistent Job
16+
[Tags] execute
17+
Run Keyword And Expect Error Can't find specified job: ${test_job_name}\
18+
... Start Jenkins Job ${test_job_name}
19+
20+
Run Existent Unparameterized Job Without Params
1821
[Tags] execute
1922
[Setup] Create Jenkins Job ${test_job_name}
2023
[Teardown] Delete Jenkins Job ${test_job_name}
2124
Start Jenkins Job ${test_job_name}
2225

23-
Run Inexistent Job
26+
Run Existent Unparameterized Job With Params
2427
[Tags] execute
25-
Run Keyword And Expect Error There is no specified job in Jenkins: ${test_job_name}\
26-
... Start Jenkins Job ${test_job_name}
28+
[Setup] Create Jenkins Job ${test_job_name}
29+
[Teardown] Delete Jenkins Job ${test_job_name}
30+
Run Keyword And Expect Error This is not parameterized job, you don't have to no specify params dicitionary\
31+
... Start Jenkins Job ${test_job_name} ${job_parameterized_scratch_parameters}
2732

33+
Run Existent Parameterized Job With Params
34+
[Tags] execute
35+
[Setup] Create Job From Template ${test_job_name} ${job_parameterized_scratch}
36+
[Teardown] Delete Jenkins Job ${test_job_name}
37+
${build} = Start Jenkins Job ${test_job_name} ${job_parameterized_scratch_parameters}
2838

29-
# TODO: Test with params, also add functionality for methods (params)
39+
Run Existent Parameterized Job Without Params
40+
[Tags] execute
41+
[Setup] Create Job From Template ${test_job_name} ${job_parameterized_scratch}
42+
[Teardown] Delete Jenkins Job ${test_job_name}
43+
Run Keyword And Expect Error This is parameterized job, you have to specify params dicitionary\
44+
... Start Jenkins Job ${test_job_name}
45+
46+
Compare Nuild Number
47+
[Tags] execute
48+
[Setup] Create Jenkins Job ${test_job_name}
49+
[Teardown] Delete Jenkins Job ${test_job_name}
50+
${build_number} = Start Jenkins Job ${test_job_name}
51+
${next_build_before} = Get Next Build Number ${test_job_name}
52+
Should Be Equal As Integers ${next_build_before} ${build_number + 1}

atest/jobs.robot

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
*** Settings ***
22
Library Collections
3+
Library OperatingSystem
34
Library JenkinsLibrary
5+
Resource lib/jenkins_keywords.robot
46
Suite Setup Set Jenkins Server url=${jenkins_address} username=admin password=admin
57

6-
*** Variables ***
7-
${test_job_name} test_job
8-
${second_test_job_name} blablabla_job
9-
108
*** Test Cases ***
119
Get One Existent Job
1210
[Tags] job
@@ -38,6 +36,15 @@ Create Existent Job
3836
Run Keyword And Expect Error Specified job already exists: ${test_job_name}\
3937
... Create Jenkins Job ${test_job_name}
4038

39+
Create Job From Template
40+
[Tags] job
41+
[Setup] Create Job From Template ${test_job_name} ${job_parameterized_scratch}
42+
[Teardown] Delete Jenkins Job ${test_job_name}
43+
${parameters} = Get Jenkins Job Parameters ${test_job_name}
44+
Should Be True ${parameters}
45+
Should Be Equal param_string ${parameters[0]['name']}
46+
Should Be Equal param_bool ${parameters[1]['name']}
47+
4148
Delete Inexistent Job
4249
[Tags] job
4350
Run Keyword And Expect Error There is no specified job in Jenkins: ${test_job_name}\
@@ -65,25 +72,24 @@ Disable Enabled Job
6572
[Teardown] Delete Jenkins Job ${test_job_name}
6673
Disable Jenkins Job ${test_job_name}
6774

68-
*** Keywords ***
69-
Create And Disable Job
70-
Create Jenkins Job ${test_job_name}
71-
Disable Jenkins Job ${test_job_name}
72-
73-
Create Multiple Jobs
74-
Create Jenkins Job ${test_job_name}
75-
Create Jenkins Job ${second_test_job_name}
75+
Get Job XML
76+
[Tags] job
77+
[Setup] Create Jenkins Job ${test_job_name}
78+
[Teardown] Delete Jenkins Job ${test_job_name}
79+
${job_xml} = Get Jenkins Job XML ${test_job_name}
80+
Should Start With ${job_xml} <?xml version=
7681

77-
Delete Multiple Jobs
78-
Delete Jenkins Job ${test_job_name}
79-
Delete Jenkins Job ${second_test_job_name}
82+
Get Job And Compare XML
83+
[Tags] job
84+
[Setup] Create Job From Template ${test_job_name} ${job_parameterized_scratch}
85+
[Teardown] Delete Jenkins Job ${test_job_name}
86+
${job_xml} = Get Jenkins Job XML ${test_job_name}
87+
${template_xml} = Get File ${templates_dir}/${job_parameterized_scratch}
88+
Should Be Equal As Strings ${job_xml} ${template_xml}
8089

81-
Check Multiple Jobs
82-
${jobs} = Get Jenkins Jobs
83-
Should Be True ${jobs}
84-
${second_job} = Get From List ${jobs} 0
85-
Should Be Equal ${second_job['name']} ${second_test_job_name}
86-
Should Be Equal ${second_job['url']} ${jenkins_address}/job/${second_test_job_name}/
87-
${first_job} = Get From List ${jobs} 1
88-
Should Be Equal ${first_job['name']} ${test_job_name}
89-
Should Be Equal ${first_job['url']} ${jenkins_address}/job/${test_job_name}/
90+
Check Job Parameters (parameters is inexistent)
91+
[Tags] job
92+
[Setup] Create Jenkins Job ${test_job_name}
93+
[Teardown] Delete Jenkins Job ${test_job_name}
94+
${parameters} = Get Jenkins Job Parameters ${test_job_name}
95+
Should Not Be True ${parameters}

atest/lib/jenkins_keywords.robot

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
*** Settings ***
2+
Library Collections
3+
Library OperatingSystem
4+
Library JenkinsLibrary
5+
6+
*** Keywords ***
7+
Create And Disable Job
8+
Create Jenkins Job ${test_job_name}
9+
Disable Jenkins Job ${test_job_name}
10+
11+
Create Multiple Jobs
12+
Create Jenkins Job ${test_job_name}
13+
Create Jenkins Job ${second_test_job_name}
14+
15+
Delete Multiple Jobs
16+
Delete Jenkins Job ${test_job_name}
17+
Delete Jenkins Job ${second_test_job_name}
18+
19+
Check Multiple Jobs
20+
${jobs} = Get Jenkins Jobs
21+
Should Be True ${jobs}
22+
${second_job} = Get From List ${jobs} 0
23+
Should Be Equal ${second_job['name']} ${second_test_job_name}
24+
Should Be Equal ${second_job['url']} ${jenkins_address}/job/${second_test_job_name}/
25+
${first_job} = Get From List ${jobs} 1
26+
Should Be Equal ${first_job['name']} ${test_job_name}
27+
Should Be Equal ${first_job['url']} ${jenkins_address}/job/${test_job_name}/
28+
29+
Create Job From Template
30+
[Arguments] ${job_name} ${template_file}
31+
${template} = Get File ${templates_dir}/${template_file}
32+
Create Jenkins Job ${job_name} ${template}
33+
34+
Create Job And Run Multiple Builds
35+
[Arguments] ${job_name} ${count}=2
36+
Create Jenkins Job ${job_name}
37+
:FOR ${run} IN RANGE ${count}
38+
\ Start Jenkins Job ${job_name}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.1" encoding="UTF-8"?><project>
2+
<description/>
3+
<keepDependencies>false</keepDependencies>
4+
<properties>
5+
<hudson.model.ParametersDefinitionProperty>
6+
<parameterDefinitions>
7+
<hudson.model.StringParameterDefinition>
8+
<name>param_string</name>
9+
<description/>
10+
<defaultValue>param_string</defaultValue>
11+
<trim>false</trim>
12+
</hudson.model.StringParameterDefinition>
13+
<hudson.model.BooleanParameterDefinition>
14+
<name>param_bool</name>
15+
<description/>
16+
<defaultValue>true</defaultValue>
17+
</hudson.model.BooleanParameterDefinition>
18+
</parameterDefinitions>
19+
</hudson.model.ParametersDefinitionProperty>
20+
</properties>
21+
<scm class="hudson.scm.NullSCM"/>
22+
<canRoam>true</canRoam>
23+
<disabled>false</disabled>
24+
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
25+
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
26+
<triggers/>
27+
<concurrentBuild>false</concurrentBuild>
28+
<builders>
29+
<hudson.tasks.Shell>
30+
<command>echo $param_shell
31+
echo $param_bool
32+
sleep 15</command>
33+
</hudson.tasks.Shell>
34+
</builders>
35+
<publishers/>
36+
<buildWrappers/>
37+
</project>

setup.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from os.path import join, dirname
2-
from setuptools import setup
2+
from setuptools import setup, find_packages
33

44
exec(open(join(dirname(__file__),
55
'src', 'JenkinsLibrary', 'version.py')).read())
@@ -11,15 +11,30 @@
1111
'requests==2.18.4'
1212
]
1313

14+
CLASSIFIERS = '''
15+
License :: OSI Approved :: Apache Software License
16+
Development Status :: 5 - Production/Stable
17+
Programming Language :: Python :: 2
18+
Programming Language :: Python :: 2.7
19+
Programming Language :: Python :: 3
20+
Programming Language :: Python :: 3.3
21+
Programming Language :: Python :: 3.4
22+
Programming Language :: Python :: 3.5
23+
Programming Language :: Python :: 3.6
24+
Topic :: Software Development :: Testing
25+
Framework :: Robot Framework
26+
'''
27+
1428
setup(
1529
name=PACKAGE,
1630
package_dir={'': 'src'},
17-
packages=['JenkinsLibrary'],
31+
packages=find_packages('src'),
1832
version=VERSION,
1933
description=DESCRIPTION,
2034
author='Mikhail Naletov',
2135
author_email='admin@markeloff.net',
2236
url='https://github.com/okgolove/robotframework-jenkins',
2337
keywords=['jenkins', 'robotframework', 'robot', 'testing'],
24-
install_requires=REQUIREMENTS
38+
classifiers=CLASSIFIERS,
39+
install_requires=REQUIREMENTS,
2540
)

0 commit comments

Comments
 (0)