'checking out specific directory out of a GIT repo
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".
Solution 1:[1]
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 HEADThe 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>"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | VonC |
