Skip to content

cloudbees-io/configure-git-global-credentials

Repository files navigation

CloudBees action: Configure Git global credentials

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.

Inputs

Table 1. Input details
Input name Data type Required? Description

repositories

String

Yes

Repository clone URL. https://github.com/user/repo For listing multiple repositories, CloudBees recommends using a line break separator, although the repositories parameter is a whitespace and/or comma-separated list.

ssh-key

String

No

SSH key used to fetch the repository. The SSH key used for fetching a repository using it’s SSH clone URL (passed via the repositories input). The SSH key input is only relevant when the user defines an SSH clone URL via the repositories input. In all other cases the action fetches the pre-configured credentials setup on Unify for the specified repositories.

ssh-known-hosts

String

No

A list of known SSH hosts that should be added to the global host database. Use the utility ssh-keyscan to get public SSH keys for a host.

The public keys for GitHub and Bitbucket are added by default.

ssh-strict

Boolean

No

Default is true. When true, performs strict host key checking, by adding the options StrictHostKeyChecking=yes and CheckHostIP=no to the SSH command line. Use the input ssh-known-hosts to configure additional hosts.

Usage examples

For multiple repositories, onboard the specific repositories by creating integration

In your YAML file, add:

      - name: Git global credentials
        uses: cloudbees-io/configure-git-global-credentials@v2
        with:
          repositories: |
            https://github.com/user1/repo
            https://github.com/user2/rep1

For configuring access for all repositories within a GitHub project/user namespace, you can specify the Project URL as an input: https://github.com/org/

      - name: Git global credentials
        uses: cloudbees-io/configure-git-global-credentials@v2
        with:
          repositories: https://github.com/org/

You can also specify a host URL in the repositories input to grant access to all "accessible" repositories. This is dependent on the SCM Integration and credentials, permissions configured for those credentials which is setup on Unify for this component and it’s parent Organization(s).

      - name: Git global credentials
        uses: cloudbees-io/configure-git-global-credentials@v2
        with:
          repositories: https://github.beescloud.com/

Using SSH, add the SSH key as a Secret property on Unify and use the SSH clone url in the repositories input.

Note
When defining the SSH key secret please ensure that there is a new line at the end of the secret.

In your YAML file, add:

      - name: Git global credentials
        uses: cloudbees-io/configure-git-global-credentials@v2
        with:
          repositories: "ssh://github.com/user/repo"
          ssh-key: ${{secrets.<ssh-secret-name-placeholder>}}

License

This code is made available under the MIT license.

References

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors