Search code examples
gitgroovyjenkinsjenkins-workflow

nested git checkout on groovy script (jenkins' workflow)


I'm dealing with jenkins' workflow. My project includes another big project that I'd like to use sparse checkout feature. I've found a couple of issues so far:

(1) I don't know how to clone a repo into a new directory

git url:'https://some.git.server/project.git', param1:'value1',...

(2) inside the above project perform a sparse checkout

I couldn't find any groovy syntax specification.

Below is the script version I want to do using groovy

git clone https://some.git.server/project.git
cd project/subdir
git init
git remote add -f origin https://some.git.server/another.project.git
echo Source/Base > .git\info\parse-checkout
echo Source/Core > .git\info\parse-checkout
git pull origin master 
...

Thanks in advance.


Solution

  • check SCMs out (Multiple SCMs tag), I'm afraid it will help you to answer your first question.

    About the second question I cannot answer it, but you can dig around checkout tag, it's a generic SCM command, for instance:

    checkout ([$class: '...', source: '...'])
    

    You could find an exhaustive list of workflow compatible commands.

    Regards!