add pipeline stages 62/1962/1
authorMike Marchetti <mmarchetti@sandvine.com>
Thu, 22 Jun 2017 19:18:23 +0000 (15:18 -0400)
committerMike Marchetti <mmarchetti@sandvine.com>
Thu, 22 Jun 2017 19:18:23 +0000 (15:18 -0400)
Signed-off-by: Mike Marchetti <mmarchetti@sandvine.com>
Dockerfile [new file with mode: 0644]
Jenkinsfile
devops-stages/stage-archive.sh [new file with mode: 0755]
devops-stages/stage-build.sh [new file with mode: 0755]
devops-stages/stage-test.sh [new file with mode: 0755]

diff --git a/Dockerfile b/Dockerfile
new file mode 100644 (file)
index 0000000..ff46866
--- /dev/null
@@ -0,0 +1,3 @@
+FROM ubuntu:16.04
+
+RUN apt-get update && apt-get -y install git make python
index 92a5046..e30c94b 100644 (file)
@@ -1,7 +1,64 @@
-pipeline {
-    agent any
-    stages {
-        stage("test") {
+def Get_MDG(project) {
+    // split the project.
+    def values = project.split('/')
+    if ( values.size() > 1 ) {
+        return values[1]
+    }
+    // no prefix, likely just the project name then
+    return project
+}
+
+def project_checkout() {
+    // checkout the project
+    git url: "https://osm.etsi.org/gerrit/${GERRIT_PROJECT}"
+
+    sh "git fetch origin ${GERRIT_REFSPEC}"
+    if (GERRIT_PATCHSET_REVISION.size() > 0 ) {
+        sh "git checkout -f ${GERRIT_PATCHSET_REVISION}"
+    }
+}
+
+def devops_checkout() {
+    dir('devops') {
+        git url: 'https://osm.etsi.org/gerrit/osm/devops'
+    }
+}
+
+node {
+    stage('Prepare') {
+        sh 'env'
+        devops_checkout()
+    }
+
+    stage('Checkout') {
+        project_checkout()
+    }
+
+    container_name = "${GERRIT_PROJECT}-${GERRIT_BRANCH}"
+
+    mdg = Get_MDG("${GERRIT_PROJECT}")
+    println("MDG is ${mdg}")
+
+    stage('Docker-Build') {
+        sh "docker build -t ${container_name} ."
+    }
+
+    withDockerContainer("${container_name}") {
+        stage('Docker-Setup') {
+            sh '''
+               groupadd -o -g $(id -g) -r jenkins
+               useradd -o -u $(id -u) --create-home -r -g  jenkins jenkins
+               '''
+        }
+        stage('Test') {
+            sh 'devops-stages/stage-test.sh'
+        }
+        stage('Build') {
+            sh 'devops-stages/stage-build.sh'
+        }
+        stage('Archive') {
+            sh 'devops-stages/stage-archive.sh'
+            archiveArtifacts artifacts: "dists/**,pool/${mdg}/*.deb", fingerprint: true
         }
     }
 }
diff --git a/devops-stages/stage-archive.sh b/devops-stages/stage-archive.sh
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/devops-stages/stage-build.sh b/devops-stages/stage-build.sh
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/devops-stages/stage-test.sh b/devops-stages/stage-test.sh
new file mode 100755 (executable)
index 0000000..e69de29