From 2adcba05392a63f9a586ad7916deffb8f2086aae Mon Sep 17 00:00:00 2001
From: Till Wegmueller <toasterson@gmail.com>
Date: Mon, 29 Nov 2021 23:20:11 +0100
Subject: [PATCH] Adding PR cleanup to CI and reformated with shfmt

---
 Jenkinsfile |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index a2e2de1..26fd7a3 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,7 +1,16 @@
 // OpenIndiana Userland Jenkinsfile, (c) 2021 Olaf Bohlen <olbohlen@eenfach.de>
+// OpenIndiana Userland Jenkinsfile, (c) 2021 Till Wegmueller <toasterson@gmail.com>
 
 // ensure the jenkins user can modify SMF services, e.g. run:
 // usermod -A solaris.smf.* -P 'Service Operator' jenkins
+
+// To add more things have a look at the documentation under
+// https://github.com/jenkinsci/pipeline-github-plugin
+
+// TODO: Do not build draft PR's
+// TODO: Figure out what to do when no Makefile was changed
+// TODO: have two build Jobs (one for oi/hipster and another for this PR)
+// TODO: matrix build against multiple configuration gcc-7, gcc-10, gcc-11 and encumbered vs. without encumbered
 
 pipeline {
     options {
@@ -16,9 +25,8 @@
     stages {
         stage('setup stage') {
             steps {
-		sh './tools/jenkinshelper.ksh -s setup'
+		        sh './tools/jenkinshelper.ksh -s setup'
             }
-
         }
 
         stage('build changed components') {
@@ -27,11 +35,26 @@
             }
         }
 
-	stage('create initial pkgdepotd.conf if not exists') {
-	    steps {
-		sh './tools/jenkinshelper.ksh -s prepare_pkgdepotd'
+	    stage('create initial pkgdepotd.conf if not exists') {
+    	    steps {
+                sh './tools/jenkinshelper.ksh -s prepare_pkgdepotd'
+	          }
 	    }
-	}
+
+        stage('cleanup') {
+            when {
+                 not {
+                     environment name: 'CHANGE_ID', value: 'null'
+                 }
+            }
+            steps {
+                script {
+                    if (pullRequest.state == "closed" || pullRequest.merged) {
+                        sh './tools/jenkinshelper.ksh -s cleanup_pr'
+                    }
+                }
+            }
+        }
     }
 }
 

--
Gitblit v1.9.3