Use this action to set up a Git global configuration for use in CloudBees workflows. This action authenticates the current user, by default scoped to repositories in the same organization as the workflow repository. After this step is run, all steps using the Git CLI in the same job authenticate with these credentials.
|
Tip
|
You can use this action to avoid failures due to lack of pre-authentication of private repositories. For example, if you are building a Go module that depends on other private modules, private repository authentication must be already in place for go mod download to run successfully.
|
|
Note
|
This action may set up authentication for different types of Git global configurations, including:
CloudBees recommends that if you are using a Git client other than the official Git CLI, make sure that your Git client supports the authentication configuration applied by this action. |
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Yes |
The token to configure. |
|
String |
Required if |
The repositories accessible via the token.
For listing multiple repositories, CloudBees recommends using a line break separator, although the |
|
String |
CloudBees recommends specifying |
The source code management (SCM) provider. |
|
String |
No |
The GitHub server URL. |
|
String |
No |
The Bitbucket server URL. |
|
String |
No |
The GitLab server URL. |
Use this action to configure a Git token from a secret. This action does not currently work with configuring an SSH private key from a secret, or using CloudBees platform authentication.
Use a token for all repositories in the same organization as the workflow repository.
For example, the action is run from https://github.com/example/myjob repository, then the personal access token is configured for all repositories in the https://github.com/example organization.
In your YAML file, add:
- name: Git global credentials
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_TOKEN }}Use a token for only the named repositories in the same SCM provider as the workflow repository.
In your YAML file, add:
- name: Git global credentials
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_TOKEN }}
repositories: |
example/foo
example/barUse a token for all repositories in a named organization in a different SCM provider from that of the workflow repository.
In your YAML file, add:
- name: Git global credentials
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_GITLAB_TOKEN }}
provider: gitlab
repositories: example/*Use a token for a GitHub Enterprise Server.
In your YAML file, add:
- name: Git global credentials
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_GHE_TOKEN }}
provider: github
github-server-url: https://my-ghes-server.example.com
repositories: "*/*"Use a token for GitHub SaaS, Bitbucket, or GitLab SCM provider instances.
In your YAML file, add:
- name: Git global credentials
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_SCM_TOKEN }}
provider: bitbucket
bitbucket-server-url: https://my-bbdc-server.example.com
repositories: "*/*"Use a token when a step is repeated multiple times in the same job, resulting in layered authentication. In the case of multiple steps matching the same authentication, the last one takes precedence.
In your YAML file, add:
- name: Git global credentials for GitHub
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_GITHUB_TOKEN }}
repositories: |
example/foo
example/bar
- name: Git global credentials for GHE
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_GHE_TOKEN }}
provider: github
github-server-url: https://my-ghes-server.example.com
repositories: "*/*"
- name: Git global credentials for GitLab
uses: cloudbees-io/configure-git-global-credentials@v1
with:
token: ${{ secrets.MY_GITLAB_TOKEN }}
provider: gitlab
repositories: example/*This code is made available under the MIT license.
-
Learn more about using actions in CloudBees workflows.
-
Learn about the CloudBees platform.