Use this action to check out a Git repository under $CLOUDBEES_WORKSPACE
, to allow your workflow to access the repository.
Check out a repository from any of the following source code management (SCM) providers:
-
GitHub
-
Bitbucket
-
Bitbucket Data Center
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 the git
executable.
All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Workflow run tokens
The CloudBees workflow run token (cloudbees.api.token
) is used to fetch an app access token from the SCM provider if neither a personal access token nor an SSH key are specified.
|
Inputs
Input name | Data type | Required? | Description |
---|---|---|---|
|
String |
No |
The base URL for the Bitbucket instance to clone. The environment defaults, such as |
|
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 |
|
String |
No |
The base URL for the GitHub instance to clone. The environment defaults, such as |
|
Boolean |
No |
Default is |
|
String |
No |
The relative repository path under the |
|
Boolean |
No |
The default value is |
|
String |
No |
The SCM provider hosting the repository. For example GitHub, BitBucket, or custom. The default 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 |
The repository name with owner. For example, |
|
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 |
|
String |
No |
The PAT used to fetch the repository. The PAT is configured with the local Git config, which enables your scripts to run authenticated Git commands. |
|
String |
No |
The authentication type of the token being used.
Supported values are |
Outputs
Output name | Data type | Description |
---|---|---|
|
String |
The commit SHA for the source repository. |
|
String |
The commit URL from the source repository. Returns Unavailable if the commit is from a local merge. |
|
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. |
Usage examples
The following basic example uses this action to check out a GitHub repository:
- name: Check out my GitHub repo uses: https://github.com/cloudbees-io/checkout@v1 (1) with: repository: my-name/my-repo-name
1 | The action’s full URL is not required here, because the action and workflow both reside with the same SCM provider. However, CloudBees recommends that you clearly identify the repository with the full action URL. |
The following example uses this action to check out a Bitbucket (cloud) or Bitbucket Data Center repository:
- name: Check out my Bitbucket repo uses: https://github.com/cloudbees-io/checkout@v1 (1) with: repository: my-name/my-repo-name
1 | You must use the action’s full URL for checking out Bitbucket or Bitbucket Data Center repositories in this case, because the action repository is hosted on GitHub. |
The following example uses this action to check out the test
branch of a Bitbucket repository for a workflow hosted in a GitHub repository:
- name: Check out Bitbucket repo for GitHub workflow uses: https://github.com/cloudbees-io/checkout@v1 with: provider: bitbucket repository: my-name/my-repo-name bitbucket-server-url: https://bitbucket.org ref: test token: ${{ secrets.MY_BITBUCKET_TOKEN }}
The following example uses this action to check out the full history of the default branch of a GitHub repository, using an SSH key. The authentication does not persist.
- name: Check out GitHub repo uses: https://github.com/cloudbees-io/checkout@v1 with: repository: my-name/my-repo-name github-server-url: https://github.com ssh-key: {{ secrets.MY_SSH_KEY }} persist-credentials: false fetch-depth: 0
The following example uses this action to check out the last commit of the default branch of a GitHub repository, using the CloudBees workflow run token. Submodules are recursively checked out.
The following example uses this action to check out the last commit of the default branch of a GitHub repository, using the CloudBees workflow run token. Submodules are recursively checked out.
The following example uses outputs
to display action input values.