从GIT存储库中查看特定目录

发布于 2025-01-25 04:28:15 字数 668 浏览 3 评论 0原文

我想从Jenkins Pipeline中的GIT存储库中查看一个特定的文件夹(例如:10.0-rc-3)。

我在git reto中的结构以下结构: https://gitlab.xxx.org/titan /testing/test-project/

10.0-rc-1

10.0-rc-2

10.0-rc-3

我尝试了以下代码,但这无效,

stage(checkout specific folder){
scm:[
userRemoteConfigs:[
[
credintialsId: 'MySecretId',
url: 'https://gitlab.xxx.org/Titan/Testing/Test-project.git'
name: env.gitlabTargetNamespace
]
]
]
sh "git archive --remote='https://gitlab.xxx.org/Titan/Testing/Test-project/' 'master' '10.0-RC-3'
}


我会遇到错误”。

I want to check out a specific folder (as per below, e.g.: 10.0-RC-3) from a GIT repo in jenkins pipeline.

I have below structure in GIT repo : https://gitlab.xxx.org/Titan/Testing/Test-project/

10.0-RC-1

10.0-RC-2

10.0-RC-3

I tried with below code, but that didn't work

stage(checkout specific folder){
scm:[
userRemoteConfigs:[
[
credintialsId: 'MySecretId',
url: 'https://gitlab.xxx.org/Titan/Testing/Test-project.git'
name: env.gitlabTargetNamespace
]
]
]
sh "git archive --remote='https://gitlab.xxx.org/Titan/Testing/Test-project/' 'master' '10.0-RC-3'
}


i getting error as "fatal:operation not supported by protocol".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如何视而不见 2025-02-01 04:28:15

您可能需要使用SSH URL代替Git Archive与GitLab存储库一起使用。参见此线程作为一个例证

  git档案-emote 路径/到/project.git -o test.zip头
 

SSH连接的格式应如下:

  git@< hostName>:path/to/to/project.git
 

但是您也可以考虑 api调用

curl --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.com/api/v4/projects/<project_id>/repository/archive?sha=<commit_sha>&path=<path>"

You might need to use an SSH URL instead for git archive to work with GitLab repositories. See this thread as an illustration.

git archive --remote [email protected]:path/to/project.git -o test.zip HEAD

The format for your SSH connection should be as follows:

git@<hostname>:path/to/project.git

But you could also consider an API call

curl --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.com/api/v4/projects/<project_id>/repository/archive?sha=<commit_sha>&path=<path>"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文