Use this action to check out a Git repository under $CLOUDBEES_WORKSPACE
, to allow your workflow to access the repository.
Your authentication for the checked-out repository is persisted in the local Git config file by default, so your scripts can run authenticated Git commands in any container image that has Git executables.
The CloudBees API token is used to fetch an app access token if no SSH key provided.
Input name | Data type | Required? | Description |
---|---|---|---|
|
Boolean |
No |
Default is |
|
String |
No |
The CloudBees API Token to use when fetching SCM token when a |
|
Number |
No |
Number of commits to fetch.
Default is |
|
Boolean |
No |
Default is |
|
String |
No |
The relative repository path under the |
|
Boolean |
No |
The default value is |
|
String |
No |
The branch, tag or SHA to check out. The action uses the default branch, except when checking out the triggering workflow repository. In that instance, the event reference or SHA is used. |
|
String |
No |
Repository clone URL.
For example, https://github.com/cloudbees-io/checkout.
Default value is |
|
Boolean |
No |
Default is |
|
String |
No |
SSH key used to fetch the repository. The SSH key is configured with the local Git config, which enables scripts to run authenticated Git commands. We recommend using the platform authentication instead of SSH keys. Do not use SSH keys if using the authentication built into the platform for the workflow repository or authentication using the |
|
String |
No |
A list of known SSH hosts that should be added to the global host database. Use the utility The public keys for GitHub and Bitbucket are implicitly added by default. |
|
Boolean |
No |
Default is |
|
Boolean |
No |
Default is |
Output name | Data type | Description |
---|---|---|
|
String |
The commit SHA for the source repository. |
|
String |
The ref or branch for the checked-out repository. Returns empty when in a detached-head state or if the commit is from a local merge. |
|
String |
The URL of the cloned repository. |
In the YAML file, all values are required, unless otherwise noted. Default values are included in the example YAML file below. Refer to the notes for options and details.
Note
|
CloudBees recommends:
|
In your YAML file, add:
- name: Check out repo
uses: cloudbees-io/checkout@v2
id: checkout
with:
repository: ${{ cloudbees.repositoryUrl }}
ref: ''
ssh-key: ''
ssh-known-hosts: ''
ssh-strict: true
persist-credentials: true
path: ''
clean: true
fetch-depth: 1
lfs: false
submodules: false
set-safe-directory: true
- name: Display outputs
uses: docker://golang:1.20.3-alpine3.17
shell: sh
run: |
echo Repository URL = ${{ steps.checkout.outputs.repository-url }}
echo Commit ID = ${{ steps.checkout.outputs.commit }}
echo Ref = ${{ steps.checkout.outputs.ref }}
This code is made available under the MIT license.
-
Learn more about using actions in CloudBees workflows.
-
Learn about the CloudBees platform.