如何在单个管道作业中检出多个 tfs 文件夹
How to checkout multiple tfs folders in a single pipeline job
假设有一个 TFS 存储库
http://tfstta.example.com:8080/tfs/DefaultCollection/
并假设该存储库中有五个文件夹
文件夹1,
文件夹2,
文件夹3,
文件夹4,
文件夹5
在使用 TFS 插件的 Jenkins 中,我可以像下面这样配置以从存储库克隆单个文件夹,
Here is single folder cloaning configuration(请查看)
如何一次克隆多个文件夹?
使用以下结构进行管道多重检出:
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
您可以查看以下代码:
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}'])
最后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
}
假设有一个 TFS 存储库
http://tfstta.example.com:8080/tfs/DefaultCollection/
并假设该存储库中有五个文件夹
文件夹1, 文件夹2, 文件夹3, 文件夹4, 文件夹5
在使用 TFS 插件的 Jenkins 中,我可以像下面这样配置以从存储库克隆单个文件夹,
Here is single folder cloaning configuration(请查看)
如何一次克隆多个文件夹?
使用以下结构进行管道多重检出:
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
您可以查看以下代码:
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}'])
最后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
}