All Projects → flosell → lambdacd-git

flosell / lambdacd-git

Licence: Apache-2.0 license
Git support for LambdaCD

Programming Languages

clojure
4091 projects
shell
77523 projects

Projects that are alternatives of or similar to lambdacd-git

clearml-server-helm
ClearML Server for Kubernetes Clusters Using Helm
Stars: ✭ 18 (+0%)
Mutual labels:  version-control
OctoPrint-GitFiles
With this plugin, you can use a github/gitlab repository for keeping your OctoPrint Files collection up-to-date.
Stars: ✭ 28 (+55.56%)
Mutual labels:  version-control
breezy
A Distributed Version Control System with a Friendly UI
Stars: ✭ 76 (+322.22%)
Mutual labels:  version-control
Bash-Git
D-Lab's 3 hour introduction to basic Bash commands and using version control with Git and Github.
Stars: ✭ 126 (+600%)
Mutual labels:  version-control
gg
Git with less typing
Stars: ✭ 55 (+205.56%)
Mutual labels:  version-control
powerbi-vcs
WIP (properly) version control and collaborate on your *.pbi{tx} files
Stars: ✭ 78 (+333.33%)
Mutual labels:  version-control
Tutorials
🗒 codebar's tutorials
Stars: ✭ 231 (+1183.33%)
Mutual labels:  version-control
gradle-GitVersioner
generates a project version for the given git project to distinguish between builds
Stars: ✭ 80 (+344.44%)
Mutual labels:  version-control
blendgit
manage versions of Blender documents using Git
Stars: ✭ 93 (+416.67%)
Mutual labels:  version-control
python-aos-lesson
Python for Atmosphere and Ocean Scientists
Stars: ✭ 78 (+333.33%)
Mutual labels:  version-control
christian-git
A wrapper for Git to sanctify your version control workflow. ✝️
Stars: ✭ 84 (+366.67%)
Mutual labels:  version-control
10-days-of-git-and-github
asabeneh.github.io/10-days-of-git-and-github/
Stars: ✭ 786 (+4266.67%)
Mutual labels:  version-control
AutoVer
Configurable automatic or real time backup and personal versioning system
Stars: ✭ 65 (+261.11%)
Mutual labels:  version-control
git-rdm
A research data management plugin for the Git version control system.
Stars: ✭ 34 (+88.89%)
Mutual labels:  version-control
versionaire
Provides an immutable, thread-safe, and semantic version type.
Stars: ✭ 71 (+294.44%)
Mutual labels:  version-control
togepi
A version control system built using Python and DropBox API
Stars: ✭ 23 (+27.78%)
Mutual labels:  version-control
pro.fessional.wings
WingsBoot=BKB+飞鞋+SpringBoot。其核心价值是:①使团队快速实现业务目标;②快速偿还技术债务;③安全的面向程序和业务重构。
Stars: ✭ 78 (+333.33%)
Mutual labels:  version-control
Reproducibilidad
Reproducible Science: what, why, how
Stars: ✭ 39 (+116.67%)
Mutual labels:  version-control
Exact
An open source online platform for collaborative image labeling of almost everything
Stars: ✭ 47 (+161.11%)
Mutual labels:  version-control
nb-clean
Clean Jupyter notebooks of outputs, metadata, and empty cells, with Git integration
Stars: ✭ 72 (+300%)
Mutual labels:  version-control

Git support for LambdaCD

Provides Git support for LambdaCD. Will replace the lambdacd.steps.git namespace in the the lambdacd-git library.

Status

Build Status

Clojars Project

Usage

;; project.clj
:dependencies [[lambdacd-git "<most recent version>"]]
;; import:
(:require [lambdacd-git.core :as lambdacd-git])

Complete Example

You'll find a complete example here: example/simple_pipeline.clj

Waiting for a commit

(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/"))))

Using Web- or Post-Commit Hooks instead of Polling

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

Notice that this doesn't necessarily trigger a new build. Similar to how Jenkins works, a notification just forces a check for changes.

Cloning a Repository

(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)))

Get details on commits since last build

(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)))

Working with more than one repository

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

Tagging versions

You can tag any revision:

(defn deploy-to-live [args ctx]
  ;do deploy
  (let [cwd (:cwd args)]
    (lambdacd-git/tag-version ctx cwd repo "HEAD" (str "live-" version))))

(def pipeline-structure
  `(; ...
    (with-workspace
      ;...
      deploy-to-live
      do-something)))

Configuration (versions >= 0.3.0)

Certain values can be configured using LambdaCDs config-map. The following example shows the default:

(let [config  {:git {:timeout              20                               ; the timeout for remote operations in seconds
                     :credentials-provider (CredentialsProvider/getDefault) ; the credentials-provider to use for HTTPS clones (e.g. UsernamePasswordCredentialsProvider)
                     :ssh {:use-agent                true                         ; whether to use an SSH agent
                           :known-hosts-files        ["~/.ssh/known_hosts" 
                                                      "/etc/ssh/ssh_known_hosts"] ; which known-hosts files to use for SSH connections 
                           :identity-file            nil                          ; override the normal SSH behavior and explicitly specify a key to use
                           :strict-host-key-checking nil}}}]                      ; override the normal SSH behavior and explicitly set the StrictHostKeyChecking setting. Off by default, can be set to yes,no or ask
  (lambdacd/assemble-pipeline pipeline-structure config))

The same parameters can also be used as parameters to git operations directly, e.g. if different repositories need different credentials:

(defn clone [args ctx]
  (lambdacd-git/clone ctx repo branch-or-tag-or-commit-hash (:cwd args) 
                      :credentials-provider (UsernamePasswordCredentialsProvider. (System/getenv "LAMBDACD_GIT_TESTREPO_USERNAME")
                                                                                  (System/getenv "LAMBDACD_GIT_TESTREPO_PASSWORD"))))

Configuration (versions < 0.3.0)

SSH Configuration

LambdaCD-Git honors the default SSH Config files from ~/.ssh/config(/etc/ssh/ssh_config currently not supported (see #23)). Use this to configure things like StrictHostKeyChecking or the IdentityFile. Alternatively, some options can be configured using ssh-init.

Authentication

Git over SSH

LambdaCD Git automatically picks up SSH-Keys in the default locations, e.g. ~/.ssh/id_rsa. SSH Agents are also supported.

Git over HTTPS

Authentication for HTTPS is supported using an instance of the JGit CredentialsProvider.

Import e.g. UsernamePasswordCredentialsProvider into your namespace:

(ns <your-pipeline-name>.core
  ;...
  (:import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider)
  ;...
  )

Add an instance to the LambdaCD config:

(let [config {:home-dir "/some/path"
              :git {:credentials-provider (UsernamePasswordCredentialsProvider. "some-username" "some-password")}}]
              ; ... 
              )

Customize SSH Client

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!)
  ; ...
  )

Development

Call ./go

License

Copyright © 2015 Florian Sellmayr

Distributed under the Apache License 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].