如何在内联 groovy 脚本中添加 git clone 操作

MD.*_*hin 4 git jenkins jenkins-groovy

我想在 jenkins 中使用内联 groovy 脚本克隆 repo。如何执行 git clone 并使用 groovy 构建应用程序。

bir*_*230 5

如果您使用 Jenkins 管道,请参阅官方文档中的示例,例如:

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

对于简单的 Groovy 脚本,您可以尝试以下操作:

 ["git", "clone", "https://github.com/jfrogdev/project-examples.git"].execute()
Run Code Online (Sandbox Code Playgroud)