如何在单个管道作业中检出多个tfs文件夹

时间:2020-03-02 10:54:14

标签: jenkins plugins tfs jenkins-pipeline checkout

假设有一个TFS存储库

http://tfstta.example.com:8080/tfs/DefaultCollection/

并假设该存储库中有五个文件夹

文件夹1, 文件夹2, 文件夹3, 文件夹4, 文件夹5

在使用TFS插件的Jenkins中,我可以进行如下配置,以从存储库中克隆单个文件夹,

Here is single folder cloaning configuration请查看

如何一次克隆多个文件夹?

3 个答案:

答案 0 :(得分:0)

使用以下结构进行多次结帐:

stages 
{
    stage("GIT-Checkout") 
    {
        steps 
        {
        checkout([$class: 'GitSCM', branches: [[name: '<PARAM>']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: '<PARAM>', relativeTargetDir: '<PARAM>', timeout: 20 ]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '<PARAM>', url: '<PARAM>']]])
        } // steps
    } // stage

    stage("GIT-Checkout2") 
    {
        steps 
        {
        checkout([$class: 'GitSCM', branches: [[name: '<PARAM>']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: '<PARAM>', relativeTargetDir: '<PARAM>', timeout: 20 ]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '<PARAM>', url: '<PARAM>']]])
        } // steps
    } // stage

    stage("GIT-Checkout3") 
    {
        steps 
        {
        checkout([$class: 'GitSCM', branches: [[name: '<PARAM>']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: '<PARAM>', relativeTargetDir: '<PARAM>', timeout: 20 ]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '<PARAM>', url: '<PARAM>']]])
        } // steps
    } // stage
} //Stages

*Replace <PARAM> with the required values

答案 1 :(得分:0)

您可以检查以下代码:

checkout([$class: 'TeamFoundationServerScm', 
credentialsConfigurer: [$class: 'AutomaticCredentialsConfigurer'], 
projectPath: '$/ProcessControlSystems/RSBatch', 
serverUrl: 'http://tfstta.example.com:8080/tfs/DefaultCollection',  
useOverwrite: true, 
useUpdate: true, 
workspaceName: 'Hudson-${JOB_NAME}-${NODE_NAME}'])

答案 2 :(得分:0)

最后This Code worked for me,谢谢所有回答。

现在,通过更改项目路径,我可以在单个groovy文件中多次使用此代码。

withCredentials([string(credentialsId: 'PASSWORD-FORMASTAPPS', variable: 'PASSWORD')]) 
{
    checkout([$class: 'TeamFoundationServerScm',
    projectPath: '$/***Folder1 path***', 
    serverUrl: 'http://example1.com:8080/tfs/DefaultCollection', 
    useOverwrite: true, 
    useUpdate: true, 
    userName: 'TEN\\Uxxxxxxx', 
    password: hudson.util.Secret.fromString(PASSWORD),
    workspaceName: 'Hudson-${JOB_NAME}-${NODE_NAME}'])
    echo password
}

withCredentials([string(credentialsId: 'PASSWORD-FORMASTAPPS', variable: 'PASSWORD')]) 
{
    checkout([$class: 'TeamFoundationServerScm',
    projectPath: '$/***Folder2 path***', 
    serverUrl: 'http://example1.com:8080/tfs/DefaultCollection', 
    useOverwrite: true, 
    useUpdate: true, 
    userName: 'TEN\\Uxxxxxxx', 
    password: hudson.util.Secret.fromString(PASSWORD),
    workspaceName: 'Hudson-${JOB_NAME}-${NODE_NAME}'])
    echo password
}