#443  Mirror remote repository locally
Stanislav N. opened 2 weeks ago

Hello, I want to be able to pull remote repository into a project inside 1dev e.g. from github or gitlab. Why:

  • To use dependencies from local repository (in case of dependency's repository disappeared from remote location)
  • To deploy third party software using a runner that has no internet access.

Maybe there are more use cases, but these are mine.

Robin Shen commented 2 weeks ago

You may add a helper project, configure its build spec to run a job with a cron schedule. The job pulls from remote repository and push into local repository. I experimented mirroring a github repo and below is the example build spec:

version: 13
- name: CI
  - !CommandStep
    name: sync
    image: alpine/git
    - git clone https://someuser:access_token@@github.com/someuser/test
    - cd test
    - git push http://someuser:access_token@@onedev_host/test
    useTTY: false
  - !ScheduleTrigger
    cronExpression: 0 0 12 * * ?
  retryCondition: never
  maxRetries: 3
  retryDelay: 30
  cpuRequirement: 500
  memoryRequirement: 256
  timeout: 3600

In production, you may want to replace access token with job secret for security reason.

Robin Shen commented 2 weeks ago

Tips: To copy a build spec, edit your build spec and switch to edit source mode, copy the content, and then switch back to edit mode for further modification.

Stanislav N. commented 2 weeks ago

Sounds like a crutch :)

I think it's better to have a separate setting for repository which will contain remote repository's URL. There are two ways I saw that in the wild:

  1. Enter URL when creating repository. This repository will be marked as mirror and all changes will be overwritten. This is gitea way.
  2. Enter URL in repository's settings. Every automatic pull will overwrite any local changes. This is Gitlab/Kallithea way.

I was speaking about something like that.

Robin Shen commented 2 weeks ago

Thanks for the info. Will add the mirror concept in future version.

issue 1 of 1
New Feature
Issue Votes (0)
Watchers (3)
issue onedev/server#443
Please wait...
Page is in error, reload to recover