From eeb0702861fe1c0c8c80b2cf1faee270f8185719 Mon Sep 17 00:00:00 2001
From: "Stefan E. Funk" <funk@sub.uni-goettingen.de>
Date: Fri, 15 Sep 2017 15:46:54 +0200
Subject: [PATCH] Jenkinsfile added.

---
 Jenkinsfile | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Jenkinsfile

diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 00000000..8f6fc2c9
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,43 @@
+node {
+  def mvnHome
+
+  stage('Preparation') {
+    git 'git://git.projects.gwdg.de/oai-pmh.git'
+    mvnHome = tool 'Maven 3.0.4'
+  }
+
+  stage('Build') {
+    sh "'${mvnHome}/bin/mvn' -U clean verify deploy -Pdhrep.deb"
+  }
+
+  stage('Publish') {
+    def pom = readMavenPom file: 'oaipmh-webapp/pom.xml'
+    def pName = pom.artifactId
+    def pVersion = pom.parent.version
+    def snapshot = pVersion.contains("SNAPSHOT")
+
+    if (snapshot) {
+      doDebSnapshot(pName, pVersion)
+    } else {
+      doDebRelease(pName, pVersion)
+    }
+  }
+}
+
+def doDebRelease(pname, pversion) {
+  echo "Publishing Debian package ${pname} for RELEASE version ${pversion}"
+  sh "PLOC=\$(ls ${pname}/target/*.deb); curl -X POST -F file=@\${PLOC} http://localhost:8008/api/files/${pname}-${pversion}"
+  sh "curl -X POST http://localhost:8008/api/repos/releases/file/${pname}-${pversion}"
+  sh "curl -X PUT -H 'Content-Type: application/json' --data '{}' http://localhost:8008/api/publish/:./trusty"
+  sh "rm ${pname}/target/*.deb"
+  sh "rm ${pname}/target/*.changes"
+}
+
+def doDebSnapshot(pname, pversion) {
+  echo "Publishing Debian package ${pname} for SNAPSHOT version ${pversion}"
+  sh "PLOC=\$(ls ${pname}/target/*.deb); curl -X POST -F file=@\${PLOC} http://localhost:8008/api/files/${pname}-${pversion}"
+  sh "curl -X POST http://localhost:8008/api/repos/snapshots/file/${pname}-${pversion}"
+  sh "curl -X PUT -H 'Content-Type: application/json' --data '{}'  http://localhost:8008/api/publish/:./trusty"
+  sh "rm ${pname}/target/*.deb"
+  sh "rm ${pname}/target/*.changes"
+}
-- 
GitLab