Skip to content

Commit

Permalink
Added git clone plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham149 committed Oct 16, 2021
1 parent fb01e45 commit ff29ee9
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM alpine/git

COPY clone.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/clone.sh

ENTRYPOINT [ "/usr/local/bin/clone.sh" ]
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# git-plugin
A custom git plugin to clone a repository and prints the last commit.
A custom git plugin to clone a public git repository and prints the last commit.

# Running it as part of CIE pipeline
```console
- step:
identifier: clone
name: clone
type: Plugin
spec:
image: "shubham149/git-plugin"
settings:
path: codebase
repo_url: https://github.com/shubham149/git-plugin.git
branch: main
```

# Run it locally
This clones a git repo inside codebase folder.

```console
docker run --rm \
-e PLUGIN_PATH=codebase \
-e PLUGIN_REPO_URL=https://github.com/shubham149/git-plugin.git \
-e PLUGIN_BRANCH=main \
shubham149/git-plugin
```
14 changes: 14 additions & 0 deletions clone.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -xe

# If path setting is not set, then use current directory
path=${PLUGIN_PATH:-.}
mkdir -p ${path}
cd ${path}

# Clones the public git repo and checkout to a branch
git clone ${PLUGIN_REPO_URL} .
git checkout ${PLUGIN_BRANCH}

# Prints the last commit
git log -1 --stat

0 comments on commit ff29ee9

Please sign in to comment.