Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom SSH config when clone via SSH instead of HTTP #2496

Closed
4 tasks done
sinlov opened this issue Sep 24, 2023 · 2 comments
Closed
4 tasks done

Add custom SSH config when clone via SSH instead of HTTP #2496

sinlov opened this issue Sep 24, 2023 · 2 comments
Labels
feature add new functionality

Comments

@sinlov
Copy link
Contributor

sinlov commented Sep 24, 2023

Clear and concise description of the problem

Currently woodpecker clones the repositories via HTTP, but some git ssh config must use custom config.

Suggested solution

  • workflow of this feature
  1. create custom ssh config as file map
.
└── default
    ├── config
    ├── id_rsa
    └── known_hosts
  1. setting woodpecker-agent arg WOODPECKER_CUSTOM_SSH_GROUP_ROOT

  2. config

pipeline:
  clone:
    image: woodpeckerci/plugin-git
    settings:
      custom_ssh_group:
        name: default
        dryrun_host: host_name # optional
  1. at clone step
  • copy all file custom_ssh_group setting by name to woodpecker-agent path $HOME/.ssh/ for git ssh to use

Alternative

  • custom ssh config at woodpecker agent as WOODPECKER_CUSTOM_SSH_GROUP_ROOT when $HOME/.ssh/config after workspace init. this path call custom_ssh_group_root.
    • for support use different key at different ssh clone pipline, WOODPECKER_CUSTOM_SSH_GROUP_ROOT can set from volume or local path
    • custom_ssh_group_root file map as
.
├── bar
│   ├── config
│   ├── id_rsa
│   └── known_hosts
├── default
│   ├── config
│   ├── id_rsa
│   └── known_hosts
└── foo
    ├── config
    ├── id_rsa
    └── known_hosts
  • copy all file custom_ssh_group setting by name to woodpecker-agent path $HOME/.ssh/ for git ssh to use
  • each config file format as ssh_config
  • each known_hosts file is optional
  • default folder is default ssh config, this is necessary,so less file map as
.
└── default
    ├── config
    ├── id_rsa
    └── known_hosts
  • pipeline-syntax at clone can config by
pipeline:
  clone:
    image: woodpeckerci/plugin-git
    settings:
      custom_ssh_group:
        name: default
        dryrun_host: host_name # optional

beacuse settings. ssh_key args (type string) is change git config core.sshCommand ssh -i <key>, don not use at same time

  • support settings.custom_ssh_group.dryrun_host as string can set ssh test host
    • will check config file when copy from WOODPECKER_CUSTOM_SSH_GROUP_ROOT and name set
    • copy succese, will run exec as ssh -vT <dryrun_host> for check ssh config

Additional context

No response

Validations

  • Checked that the feature isn't part of the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@sinlov sinlov added the feature add new functionality label Sep 24, 2023
@qwerty287
Copy link
Contributor

In 2.0.0, plugin-git supports ssh cloning. It must be enabled manually. Does this fix the issue? (See woodpecker-ci/plugin-git#75)

@sinlov
Copy link
Contributor Author

sinlov commented Feb 9, 2024

@qwerty287 version 2.x

with local backend mode, support clone via SSH instead of HTTP can change git global config like this

git config --global url."git@git.xxx.com:".insteadOf "https://git.xxx.com/"

so, please close this issure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature add new functionality
Projects
None yet
Development

No branches or pull requests

2 participants