From e60460a674bf104f7865fba4c009ce82709ca347 Mon Sep 17 00:00:00 2001 From: Josha von Gizycki Date: Mon, 26 Nov 2018 15:44:23 +0100 Subject: [PATCH] add wedder --- src/wanijo_pipeline/core.clj | 14 +++++++-- src/wanijo_pipeline/ui_selection.clj | 10 +++--- src/wanijo_pipeline/wedder_pipeline.clj | 41 +++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 src/wanijo_pipeline/wedder_pipeline.clj diff --git a/src/wanijo_pipeline/core.clj b/src/wanijo_pipeline/core.clj index 6c77d23..f577c81 100644 --- a/src/wanijo_pipeline/core.clj +++ b/src/wanijo_pipeline/core.clj @@ -1,7 +1,9 @@ (ns wanijo-pipeline.core (:require - [wanijo-pipeline.wanijo-pipeline :as wp] - [wanijo-pipeline.formulare-pipeline :as fp] + [wanijo-pipeline + [wanijo-pipeline :as wp] + [formulare-pipeline :as fp] + [wedder-pipeline :as wdp]] [wanijo-pipeline.ui-selection :as ui-selection] [org.httpkit.server :as http-kit] [lambdacd.runners :as runners] @@ -26,11 +28,17 @@ {:home-dir (home-dir "formulare") :name "formulare pipeline"})) +(defn wedder-pipeline [] + (lambdacd/assemble-pipeline wdp/pipeline-def + {:home-dir (home-dir "wedder") + :name "wedder pipeline"})) + (defn -main [& args] (let [wanijo-pipeline (wanijo-pipeline) formulare-pipeline (formulare-pipeline) app (ui-selection/ui-routes wanijo-pipeline - formulare-pipeline)] + formulare-pipeline + wedder-pipeline)] ;; this starts the pipeline and runs one build after the other. ;; there are other runners and you can define your own as well. (runners/start-one-run-after-another wanijo-pipeline) diff --git a/src/wanijo_pipeline/ui_selection.clj b/src/wanijo_pipeline/ui_selection.clj index 6d83615..83c5102 100644 --- a/src/wanijo_pipeline/ui_selection.clj +++ b/src/wanijo_pipeline/ui_selection.clj @@ -17,10 +17,12 @@ [:li [:a {:href "./wanijo/lambdaui/index.html"} "Wanijo"]] [:li [:a {:href "./formulare/lambdaui/index.html"} "Formulare"]]]]])) -(defn ui-routes [wanijo formulare] +(defn ui-routes [wanijo formulare wedder] (let [wanijo-app (lambdaui/ui-for wanijo :contextPath "/wanijo") - formulare-app (lambdaui/ui-for formulare :contextPath "/formulare")] + formulare-app (lambdaui/ui-for formulare :contextPath "/formulare") + wedder-app (lambdaui/ui-for wedder :contextPath "/wedder")] (routes (GET "/" [] (ui-selection)) - (context "/wanijo" [] wanijo-app) - (context "/formulare" [] formulare-app)))) + (context "/wanijo" [] wanijo-app) + (context "/formulare" [] formulare-app) + (context "/wedder" [] wedder-app)))) diff --git a/src/wanijo_pipeline/wedder_pipeline.clj b/src/wanijo_pipeline/wedder_pipeline.clj new file mode 100644 index 0000000..0a2c2f4 --- /dev/null +++ b/src/wanijo_pipeline/wedder_pipeline.clj @@ -0,0 +1,41 @@ +(ns wanijo-pipeline.wedder-pipeline + (:use [lambdacd.steps.control-flow]) + (:require [lambdacd.steps.manualtrigger :as manualtrigger] + [lambdacd.steps.shell :as lcd-shell] + [lambdacd-git.core :as lcd-git])) + +(def repo-uri "https://gitea.heevyis.ninja/josha/wedder.git") +(def repo-branch "master") + +(defn wait-for-repo [args ctx] + (lcd-git/wait-for-git ctx + repo-uri + :ref (str "refs/heads/" repo-branch))) + +(defn clone [args ctx] + (let [revision (:revision args) + cwd (:cwd args) + ref (or revision repo-branch)] + (lcd-git/clone ctx repo-uri ref cwd))) + +(defn lein [target args ctx] + (lcd-shell/bash ctx (:cwd args) (str "lein " target))) + +(defn compile [args ctx] + (lein "uberjar" args ctx)) + +(defn kill-previous [args ctx] + (lcd-shell/bash ctx "pkill -f wedder")) + +(defn deploy [args ctx] + (lcd-shell/bash ctx "/opt/wedder" "nohup java -jar target/wedder-0.1.0-SNAPSHOT.jar")) + +(def pipeline-def + `((either + manualtrigger/wait-for-manual-trigger + wait-for-repo) + (with-workspace + clone + compile + kill-previous + deploy)))