Beginnings of a CD pipeline for commiteth
This commit is contained in:
commit
27799cd8d1
|
@ -0,0 +1,10 @@
|
|||
/target
|
||||
/classes
|
||||
/checkouts
|
||||
pom.xml
|
||||
pom.xml.asc
|
||||
*.jar
|
||||
*.class
|
||||
/.lein-*
|
||||
/.nrepl-port
|
||||
/cd-pipeline-home
|
|
@ -0,0 +1,3 @@
|
|||
# commiteth-pipeline
|
||||
|
||||
A continuous delivery pipeline for commiteth
|
|
@ -0,0 +1,20 @@
|
|||
(defproject commiteth-pipeline "0.1.0-SNAPSHOT"
|
||||
:description "Continuous delivery pipeline for commiteth"
|
||||
:url "https://commiteth.com"
|
||||
:dependencies [[lambdacd "0.9.3"]
|
||||
[ring-server "0.3.1"]
|
||||
[org.clojure/clojure "1.7.0"]
|
||||
[org.clojure/tools.logging "0.3.0"]
|
||||
[org.slf4j/slf4j-api "1.7.5"]
|
||||
[ch.qos.logback/logback-core "1.0.13"]
|
||||
[ch.qos.logback/logback-classic "1.0.13"]
|
||||
[environ "1.1.0"]
|
||||
[lambdacd-git "0.2.0"]
|
||||
[compojure "1.5.2"]
|
||||
[mount "0.1.11"]
|
||||
[lambdacd-artifacts "0.2.1"]]
|
||||
:plugins [[lein-environ "1.1.0"]]
|
||||
:profiles {:uberjar {:aot :all}
|
||||
:dev {:env {:home-dir "./cd-pipeline-home"}}
|
||||
:prod {:env {:home-dir "/opt/commiteth/cd-pipeline-home"}}}
|
||||
:main commiteth-pipeline.core)
|
|
@ -0,0 +1,13 @@
|
|||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
<!-- Jetty is pretty noisy... -->
|
||||
<logger name="org.eclipse.jetty" level="INFO"/>
|
||||
</configuration>
|
|
@ -0,0 +1,43 @@
|
|||
(ns commiteth-pipeline.core
|
||||
(:require
|
||||
[commiteth-pipeline.pipeline :as pipeline]
|
||||
[ring.server.standalone :as ring-server]
|
||||
[compojure.core :refer [routes]]
|
||||
[lambdacd.ui.ui-server :as ui]
|
||||
[lambdacd.runners :as runners]
|
||||
[lambdacd.util :as util]
|
||||
[lambdacd.core :as lambdacd]
|
||||
[lambdacd-git.core :as lambdacd-git]
|
||||
[environ.core :refer [env]]
|
||||
[clojure.java.io :as io]
|
||||
[mount.core :as mount]
|
||||
[clojure.tools.logging :as log])
|
||||
(:gen-class))
|
||||
|
||||
|
||||
(def pipeline-atom (atom nil))
|
||||
|
||||
(defn start []
|
||||
(let [home-dir (io/file "/tmp/foo") #_(env :home-dir)
|
||||
config {:home-dir home-dir
|
||||
:name "commiteth pipeline"}
|
||||
pipeline (lambdacd/assemble-pipeline pipeline/pipeline-def config)]
|
||||
(reset! pipeline-atom pipeline)
|
||||
(log/info "LambdaCD Home Directory is " home-dir)
|
||||
(runners/start-one-run-after-another pipeline)
|
||||
(ring-server/serve (routes
|
||||
(ui/ui-for pipeline)
|
||||
(lambdacd-git/notifications-for pipeline))
|
||||
{:open-browser? false
|
||||
:port 8080})))
|
||||
|
||||
(defn stop []
|
||||
(lambdacd/default-shutdown-sequence (:context @pipeline-atom)))
|
||||
|
||||
(mount/defstate app
|
||||
:start (start)
|
||||
:stop (stop))
|
||||
|
||||
(defn -main [& args]
|
||||
(lambdacd-git/init-ssh!)
|
||||
(mount/start))
|
|
@ -0,0 +1,17 @@
|
|||
(ns commiteth-pipeline.pipeline
|
||||
(:require
|
||||
[commiteth-pipeline.steps :refer :all]
|
||||
[lambdacd.steps.control-flow :refer :all]
|
||||
[lambdacd.steps.manualtrigger :as manualtrigger]
|
||||
[lambdacd-git.core :as git]))
|
||||
|
||||
|
||||
(def pipeline-def
|
||||
`(
|
||||
manualtrigger/wait-for-manual-trigger
|
||||
(with-workspace
|
||||
git-clone
|
||||
git/list-changes
|
||||
build-uberjar
|
||||
run-tests
|
||||
deploy-uberjar)))
|
|
@ -0,0 +1,23 @@
|
|||
(ns commiteth-pipeline.steps
|
||||
(:require
|
||||
[lambdacd.steps.shell :as shell]
|
||||
[lambdacd-git.core :as git]
|
||||
[lambdacd-git.artifacts :as artifacts]
|
||||
[clojure.tools.logging :as log]))
|
||||
|
||||
|
||||
(def repo-uri "https://github.com/status-im/commiteth.git")
|
||||
(def repo-branch "master")
|
||||
|
||||
(defn git-clone [args ctx]
|
||||
(shell/bash ctx (:cwd args) "pwd")
|
||||
(git/clone ctx repo-uri repo-branch (:cwd args)))
|
||||
|
||||
(defn build-uberjar [args ctx]
|
||||
(shell/bash ctx (:cwd args) "lein uberjar"))
|
||||
|
||||
(defn run-tests [args ctx]
|
||||
(shell/bash ctx "/" "echo no test running for now"))
|
||||
|
||||
(defn deploy-uberjar [args ctx]
|
||||
(shell/bash ctx "/" "sudo service commiteth stop && cp target/commieth.jar /opt/commiteth && service commiteth start"))
|
Loading…
Reference in New Issue