successful.log文件)xxx为需要用户自行替换的字段,具体含义详见参数介绍-核心参数。迁移团队下所有仓库
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
迁移指定项目仓库
PLUGIN_SOURCE_PROJECT 字段根据需要自行替换,详见参数介绍
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_SOURCE_PROJECT="project1,project2" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -e PLUGIN_MIGRATE_TYPE="project" -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
迁移指定仓库
PLUGIN_SOURCE_REPO 字段根据需要自行替换,详见参数介绍
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_SOURCE_REPO="project1/repoA,project1/repoB,project2/repoC" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -e PLUGIN_MIGRATE_TYPE="repo" -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_SOURCE_URL="https://github.com" \ -e PLUGIN_SOURCE_PLATFORM="github" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_SOURCE_URL="https://gitlab.com" \ -e PLUGIN_SOURCE_PLATFORM="gitlab" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_SOURCE_URL="https://gitee.com" \ -e PLUGIN_SOURCE_PLATFORM="gitee" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
docker run --rm \ -e PLUGIN_SOURCE_USERNAME="xxx" \ -e PLUGIN_SOURCE_PASSWORD="xxx" \ -e PLUGIN_SOURCE_PLATFORM="aliyun" \ -e PLUGIN_SOURCE_AK="xxx" \ -e PLUGIN_SOURCE_AS="xxx" \ -e PLUGIN_SOURCE_ORGANIZATIONID="xxx" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
http协议
docker run --rm \ -e PLUGIN_SOURCE_USERNAME="xxx" \ -e PLUGIN_SOURCE_PASSWORD="xxx" \ -e PLUGIN_SOURCE_REPO="group1/repo1,group1/repo2,group2/repo3" \ -e PLUGIN_SOURCE_URL="https://common.example.com" \ -e PLUGIN_SOURCE_PLATFORM="common" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
ssh协议
⚠️使用ssh协议时请在当前工作目录确保有对应的私钥文件,文件名固定为ssh.key
docker run --rm \ -e PLUGIN_SOURCE_REPO="group1/repo1,group1/repo2,group2/repo3" \ -e PLUGIN_SOURCE_URL="https://common.example.com" \ -e PLUGIN_SOURCE_PLATFORM="common" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -e GIT_SSH_COMMAND='ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_SOURCE_URL="https://git.woa.com" \ -e PLUGIN_SOURCE_PLATFORM="gongfeng" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
迁移指定根组织下所有仓库
docker run --rm \ -e PLUGIN_SOURCE_GROUP="xxx" \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_SOURCE_URL="https://cnb.example1.com" \ -e PLUGIN_SOURCE_PLATFORM="cnb" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -e PLUGIN_CNB_URL="https://cnb.example2.com" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
首次运行,生成仓库列表文件 repo-path.txt
这里以CODING为例,其他平台只需在原有迁移命令基础上增加-e PLUGIN_MIGRATE_ALLOW_SELECT_REPOS="true" \参数即可:
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -e PLUGIN_MIGRATE_ALLOW_SELECT_REPOS="true" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
首次运行后,工具会在当前目录生成 repo-path.txt,请手动编辑该文件,仅保留需要迁移的仓库路径。
编辑完成后,再次运行同样的命令即可只迁移你选择的仓库:
docker run --rm \ -e PLUGIN_SOURCE_TOKEN="xxx" \ -e PLUGIN_CNB_ROOT_ORGANIZATION="xxx" \ -e PLUGIN_CNB_TOKEN="xxx" \ -e PLUGIN_MIGRATE_ALLOW_SELECT_REPOS="true" \ -v $(pwd):$(pwd) -w $(pwd) \ cnbcool/code-import
如需重新选择仓库,只需删除 repo-path.txt,重新运行上述命令即可。
清空原工作目录下的 successful.log
效果:重新同步原平台的所有仓库,已迁移至 CNB 的仓库,如在原平台有更新,会将内容增量同步至 CNB 平台。
PLUGIN_SOURCE_URL
PLUGIN_SOURCE_TOKEN
PLUGIN_SOURCE_PLATFORM
PLUGIN_SOURCE_REPO
PLUGIN_SOURCE_USERNAME
PLUGIN_SOURCE_PASSWORD
PLUGIN_SOURCE_AK
PLUGIN_SOURCE_AS
PLUGIN_SOURCE_ENDPOINT
PLUGIN_SOURCE_ORGANIZATIONID
PLUGIN_CNB_URL
PLUGIN_CNB_TOKEN
PLUGIN_CNB_ROOT_ORGANIZATION
PLUGIN_SOURCE_GROUP
PLUGIN_MIGRATE_TYPE
PLUGIN_MIGRATE_CONCURRENCY
PLUGIN_MIGRATE_FORCE_PUSH
PLUGIN_MIGRATE_SKIP_EXISTS_REPO
PLUGIN_MIGRATE_USE_LFS_MIGRATE
PLUGIN_MIGRATE_ORGANIZATION_MAPPING_LEVEL
PLUGIN_MIGRATE_ALLOW_INCOMPLETE_PUSH
PLUGIN_MIGRATE_LOG_LEVEL
PLUGIN_MIGRATE_RELEASE
PLUGIN_MIGRATE_FILE_LIMIT_SIZE
PLUGIN_MIGRATE_CODE
PLUGIN_MIGRATE_SSH
PLUGIN_MIGRATE_REBASE
.cnb.yml文件,使用git rebase保证代码同步,CNB侧提交的流水线配置代码不会被覆盖
⚠️如开启该配置,将启用强制推送(PLUGIN_MIGRATE_FORCE_PUSH="true"),并在迁移工具执行的工作目录备份CNB侧代码仓库PLUGIN_SOURCE_PROJECT
PLUGIN_MIGRATE_ALLOW_SELECT_REPOS
PLUGIN_MIGRATE_USE_LFS_MIGRATE参数,详见参数介绍PLUGIN_MIGRATE_ALLOW_INCOMPLETE_PUSH详见参数介绍PLUGIN_MIGRATE_FORCE_PUSH,详见参数介绍PLUGIN_MIGRATE_ALLOW_SELECT_REPOS=true,首次运行后编辑 repo-path.txt,只保留需要迁移的仓库路径即可。repo-path.txt 文件,重新运行迁移命令即可。PLUGIN_MIGRATE_ALLOW_SELECT_REPOS=true,并确保有写入权限。