]> WPIA git - motion.git/commitdiff
add: configuration for Jenkins
authorINOPIAE <m.maengel@inopiae.de>
Tue, 15 Sep 2020 11:40:01 +0000 (13:40 +0200)
committerINOPIAE <m.maengel@inopiae.de>
Thu, 17 Sep 2020 10:36:42 +0000 (12:36 +0200)
Change-Id: Ie9deac0d0e0a61fe85964e1d9c9158f69322b521

README.md
jenkins_job.py [new file with mode: 0644]
requirements.txt

index 6b2618dc7480bbc682954e1c82c4a7d996dd9fff..4681fba5a1932027620cb3e18a664d585ed429fd 100644 (file)
--- a/README.md
+++ b/README.md
@@ -103,3 +103,79 @@ fastcgi_param USER_ROLES $motion_user_role;
 fastcgi_pass unix:/motion-socket/motion.fcgi;
 }
 ```
+
+# Configuration for a Jenkins Freestyle Project
+
+## Preconditions for Jenkins system
+
+* Python 3 installed with:
+
+  python3 virtualenv python3-pip
+
+* PostgreSQL server installed with motion database and database user
+
+
+## Add freestyle project
+
+### Source-Code-Management
+
+Adjust Git settings
+
+### Build Environment
+
+Add Bindings
+
+Add Username and password (separated)
+
+Enter username (DB_USER) and password (DB_PW) according to database credentials
+
+### Build
+
+Add build step shell
+
+Add the command
+
+```
+rm -rf env
+virtualenv -p python3 env
+. env/bin/activate
+pip3 install -r requirements.txt
+
+
+cat > config.py << EOF
+DATABASE="pq://IP-ADDRESS/motion"
+USER="${DB_USER}"
+PASSWORD="${DB_PW}"
+EOF
+
+python3 jenkins_job.py
+```
+
+If an IPv6 address is used the following needs to be added to the script to fix a bug of the IPv6 literal translation:
+(https://github.com/python-postgres/fe/issues/104)
+
+```
+patch env/lib/python3*/site-packages/postgresql/versionstring.py <<EOF
+diff --git a/postgresql/versionstring.py b/postgresql/versionstring.py
+index ccb3953..2503013 100644
+--- a/postgresql/versionstring.py
++++ b/postgresql/versionstring.py
+@@ -15,7 +15,7 @@ def split(vstr : str) -> (
+    Split a PostgreSQL version string into a tuple
+    (major,minor,patch,...,state_class,state_level)
+    """
+-   v = vstr.strip().split('.')
++   v = vstr.strip().split(' ')[0].split('.')
+    # Get rid of the numbers around the state_class (beta,a,dev,alpha, etc)
+    state_class = v[-1].strip('0123456789')
+EOF
+```
+
+### Post build actions
+
+Add Publish JUnit test result report - test report XMLs
+
+```
+python_tests_xml/*
+```
diff --git a/jenkins_job.py b/jenkins_job.py
new file mode 100644 (file)
index 0000000..56dc831
--- /dev/null
@@ -0,0 +1,13 @@
+import unittest
+import xmlrunner
+
+def runner(output='python_tests_xml'):
+    return xmlrunner.XMLTestRunner(
+        output=output
+    )
+
+def find_tests():
+    return unittest.TestLoader().discover('tests', 'test_motion.py')
+
+if __name__ == "__main__":
+    runner().run(find_tests())
index 7bfcb1f7c2fe01cbdc7b0bce1d3887dd00b4d3a6..0713e61650a17e769757df9b9d33dad7e936d675 100644 (file)
@@ -6,3 +6,4 @@ MarkupSafe==1.0
 py-postgresql==1.2.1
 Werkzeug==0.12.2
 Flask-Markdown==0.3
+xmlrunner>=1.7.7