Git

Description

NOTE: This plugin is automatically injected into your pipeline for the source repository.

This plugin enables you to clone repositories in a Vela pipeline to your build workspace.

Source Code: https://github.com/go-vela/vela-git

Registry:

Usage

NOTE:

Users should refrain from using latest as the tag for the Docker image.

It is recommended to use a semantically versioned tag instead.

Sample of cloning a repository:

steps:
  - name: clone_vela-git-test
    image: target/vela-git-slim:latest
    pull: always
    parameters:
      path: vela-git-test
      ref: refs/heads/main
      remote: https://github.com/go-vela/vela-git-test.git
      sha: ee1e671529ad86a11ed628a04b37829e71783682

Sample of cloning a repository with submodules:

steps:
  - name: clone_vela-git-test
    image: target/vela-git-slim:latest
    pull: always
    parameters:
      path: vela-git-test
      ref: refs/heads/main
      remote: https://github.com/go-vela/vela-git-test.git
      sha: ee1e671529ad86a11ed628a04b37829e71783682
+     submodules: true

Sample of cloning a repository with tags:

steps:
  - name: clone_vela-git-test
    image: target/vela-git-slim:latest
    pull: always
    parameters:
      path: vela-git-test
      ref: refs/heads/main
      remote: https://github.com/go-vela/vela-git-test.git
      sha: ee1e671529ad86a11ed628a04b37829e71783682
+     tags: true

Sample of cloning a repository and resolving LFS objects with the vela-git plugin:

steps:
  - name: clone_vela-git-test
    image: target/vela-git:latest
    pull: always
    parameters:
      path: vela-git-test
      ref: refs/heads/main
      remote: https://github.com/go-vela/vela-git-test.git
      sha: ee1e671529ad86a11ed628a04b37829e71783682
+     lfs: true

Secrets

NOTE: Users should refrain from configuring sensitive information in your pipeline in plain text.

Internal

Users can use Vela internal secrets to substitute these sensitive values at runtime:

steps:
  - name: clone_vela-git-test
    image: target/vela-git-slim:latest
    pull: always
+   secrets: [ git_username, git_password ]
    parameters:
-     username: octocat
-     password: superSecretPassword
      path: /home/go-vela_vela-git-test_1
      ref: refs/heads/main
      remote: https://github.com/go-vela/vela-git-test.git
      sha: ee1e671529ad86a11ed628a04b37829e71783682

This example will add the secrets to the clone_vela-git-test step as environment variables:

  • GIT_USERNAME=<value>
  • GIT_PASSWORD=<value>

External

The plugin accepts the following files for authentication:

ParameterVolume Configuration
password/vela/parameters/git/password, /vela/secrets/git/password
username/vela/parameters/git/username, /vela/secrets/git/username

Users can use Vela external secrets to substitute these sensitive values at runtime:

steps:
  - name: clone_vela-git-test
    image: target/vela-git-slim:latest
    pull: always
    parameters:
-     username: octocat
-     password: superSecretPassword
      path: /home/go-vela_vela-git-test_1
      ref: refs/heads/main
      remote: https://github.com/go-vela/vela-git-test.git
      sha: ee1e671529ad86a11ed628a04b37829e71783682

This example will read the secret values in the volume stored at /vela/secrets/

Parameters

NOTE:

The plugin supports reading all parameters via environment variables or files.

Any values set from a file take precedence over values set from the environment.

The following parameters are used to configure the image:

NameDescriptionRequiredDefaultEnvironment Variables
branchinitial branch to clone from repositorytruemasterPARAMETER_BRANCH
GIT_BRANCH
VELA_PULL_REQUEST_SOURCE
VELA_BUILD_BRANCH
log_levelset the log level for the plugintrueinfoPARAMETER_LOG_LEVEL
GIT_LOG_LEVEL
machinemachine name to communicate withtruegithub.comPARAMETER_MACHINE
GIT_MACHINE
VELA_NETRC_MACHINE
passwordpassword for authenticationtrueset by VelaPARAMETER_PASSWORD
GIT_PASSWORD
VELA_NETRC_PASSWORD
usernameuser name for authenticationtrueset by VelaPARAMETER_USERNAME
GIT_USERNAME
VELA_NETRC_USERNAME
pathlocal path to clone repository totrueset by VelaPARAMETER_PATH
GIT_PATH
VELA_BUILD_WORKSPACE
refreference generated for committruerefs/heads/masterPARAMETER_REF
GIT_REF
VELA_BUILD_REF
remotefull url for cloning repositorytrueset by VelaPARAMETER_REMOTE
GIT_REMOTE
VELA_REPO_CLONE
shaSHA-1 hash generated for committrueset by VelaPARAMETER_SHA
GIT_SHA
VELA_BUILD_COMMIT
submodulesenables fetching of submodulesfalsefalsePARAMETER_SUBMODULES
GIT_SUBMODULES
tagsenables fetching of tagsfalsefalsePARAMETER_TAGS
GIT_TAGS
depthenables fetching with a specific depthfalse100PARAMETER_DEPTH
GIT_DEPTH
lfs1enables resolving LFS objectsfalsefalsePARAMETER_LFS
GIT_LFS

Template

COMING SOON!

Troubleshooting

You can start troubleshooting this plugin by tuning the level of logs being displayed:

steps:
  - name: clone_vela-git-test
    image: target/vela-git-slim:latest
    pull: always
    parameters:
+     log_level: trace
      path: vela-git-test
      ref: refs/heads/main
      remote: https://github.com/go-vela/vela-git-test.git
      sha: ee1e671529ad86a11ed628a04b37829e71783682

Below are a list of common problems and how to solve them:


  1. only functional in the target/vela-git plugin. ↩︎