Provides Git support for LambdaCD.
Will replace the lambdacd.steps.git
namespace in the the lambdacd-git library.
;; project.clj
:dependencies [[lambdacd-git "<most recent version>"]]
;; import:
(:require [lambdacd-git.core :as lambdacd-git])
You'll find a complete example here: example/simple_pipeline.clj
Some features of lambdacd-git (ssh-agent support, extended known_hosts support) require customizations to JGits singleton
SSH session factory. Call init-ssh!
once, e.g. in your -main
function:
(defn -main [& args]
; ...
(lambdacd-git/init-ssh!)
; ...
)
(defn wait-for-commit-on-master [args ctx]
(lambdacd-git/wait-for-git ctx "[email protected]:flosell/testrepo"
; how long to wait when polling. optional, defaults to 10000
:ms-between-polls 1000
; which refs to react to. optional, defaults to refs/heads/master
:ref "refs/heads/master"))
; you can also pass in a regex:
(defn wait-for-commit-on-feature-branch [args ctx]
(lambdacd-git/wait-for-git ctx "[email protected]:flosell/testrepo"
:ref #"refs/heads/feature-.*"))
; you can also pass in a function
(defn wait-for-commit-on-any-tag [args ctx]
(lambdacd-git/wait-for-git ctx "[email protected]:flosell/testrepo"
:ref (fn [ref] (.startsWith ref "refs/tags/"))))
wait-for-git
can be notified about changes in a repository through an HTTP endpoint. To use this, you need to add it
to your existing ring-handlers:
(ring-server/serve (routes
(ui/ui-for pipeline)
(core/notifications-for pipeline)) ; <-- THIS
{:open-browser? false
:port 8082})
This adds an HTTP endpoint that can receive POST requests on <host>/notify-git?remote=<remote>
,
e.g. http://localhost:8082/[email protected]:flosell/testrepo
(defn clone [args ctx]
(lambdacd-git/clone ctx repo branch-or-tag-or-commit-hash (:cwd args)))
(def pipeline-structure
`(; ...
(with-workspace
clone
do-something)))
; Works well with wait-for-git:
; If no revision is given (e.g. because of manual trigger), clone falls back to the head of the master branch
(defn clone [args ctx]
(lambdacd-git/clone ctx repo (:revision args) (:cwd args)))
(def pipeline-structure
`((either
wait-for-manual-trigger
wait-for-git)
(with-workspace
clone
do-something)))
(defn clone [args ctx]
(lambdacd-git/clone ctx repo branch-or-tag-or-commit-hash (:cwd args)))
(def pipeline-structure
`(wait-for-git
(with-workspace
clone
lambdacd-git/list-changes
do-something)))
You can have clone steps that clone into different subdirectories:
(defn clone-foo [args ctx]
(lambdacd-git/clone ctx repo branch-or-tag-or-commit-hash (str (:cwd args) "/" "foo")))
(defn clone-bar [args ctx]
(lambdacd-git/clone ctx repo branch-or-tag-or-commit-hash (str (:cwd args) "/" "bar")))
(def pipeline-structure
`(; ...
(with-workspace
clone-foo
clone-bar
do-something)))
If you want to use this in combination with wait-for-git
, you need to detect which commit to use. For details, see
example/multi_repo_pipeline.clj
Call ./go
Copyright © 2015 Florian Sellmayr
Distributed under the Apache License 2.0