How can I add git clone operation in inline groovy script

MD. Ashfaqur Rahman Tahashin picture MD. Ashfaqur Rahman Tahashin · Jan 15, 2019 · Viewed 7.2k times · Source

I want to clone repo using inline groovy script in jenkins. How can I execute git clone and build the app using groovy.

Answer

biruk1230 picture biruk1230 · Jan 15, 2019

If you're using Jenkins pipelines, see examples from the official documentation, e.g.:

node {
    stage('Clone sources') {
        git url: 'https://github.com/jfrogdev/project-examples.git'
    }
}

For simple Groovy script you can try something like:

 ["git", "clone", "https://github.com/jfrogdev/project-examples.git"].execute()