jenkins下使用pipeline拉取gitlab代码

pipeline {
    agent any

    stages {
        stage('Checkout Tags') {
            steps {
                script {
                    checkout([$class: 'GitSCM', branches: [[name: "refs/tags/${fc}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CleanBeforeCheckout', deleteUntrackedNestedRepositories: true],[$class: 'CloneOption', noTags: false, shallow: true, depth: 1, honorRefspec:true], [$class: 'RelativeTargetDirectory', relativeTargetDir: "${fc}"]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '4ce8a484-4afc-4414-a0fd-e650105daba6', refspec: "+refs/tags/${fc}:refs/remotes/origin/tags/${fc}", url: "ssh://git@174.34.48.189:8022/PSW_Automation/${Project_Name}.git"]]])
                }
            }
        }
    }
}

一、相关变量的含义

changelog: false: 指定是否生成变更日志。在此处设置为false表示不生成变更日志。
poll: false: 指定是否进行轮询。在此处设置为false表示不进行轮询。
scm: 指定源代码管理配置。
branches: 指定要拉取的分支。
name: 指定要拉取的分支名称,这里使用${fc}作为变量。
doGenerateSubmoduleConfigurations: false: 指定是否生成子模块配置。在此处设置为false表示不生成子模块配置。
extensions: 指定GitSCM的扩展配置。
CleanBeforeCheckout: 在检出之前执行清理操作。
deleteUntrackedNestedRepositories: true: 删除未跟踪的嵌套存储库。
CloneOption: 克隆选项配置。
noTags: false: 克隆时包括标签。
shallow: true: 使用浅克隆。
depth: 1: 克隆深度为1。
honorRefspec: true: 尊重引用规范。
RelativeTargetDirectory: 指定相对目标目录。
relativeTargetDir: "${fc}": 设置相对目标目录为${fc}变量的值。
submoduleCfg: 子模块配置,此处为空列表。
userRemoteConfigs: 指定远程仓库配置。
credentialsId: '4ce8a484-4afc-4414-a0fd-e650105daba6': 指定凭据ID。
refspec: "+refs/tags/${fc}:refs/remotes/origin/tags/${fc}": 指定引用规范。
url: "ssh://git@174.34.48.189:8022/PSW_Automation/${Project_Name}.git": 指定Git仓库的URL,其中${Project_Name}是变量。

这些字段和配置一起构成了一个Git源代码管理配置,用于在Jenkins Pipeline中拉取tags下的工程。

checkout(changelog: false, poll: false, scm:[ c l a s s : ′ G i t S C M ′ , b r a n c h e s : [ [ n a m e : " r e f s / t a g s / class: 'GitSCM', branches: [[name: "refs/tags/ class:GitSCM,branches:[[name:"refs/tags/{fc}“]], doGenerateSubmoduleConfigurations: false, extensions: [[ c l a s s : ′ C l e a n B e f o r e C h e c k o u t ′ , d e l e t e U n t r a c k e d N e s t e d R e p o s i t o r i e s : t r u e ] , [ class: 'CleanBeforeCheckout', deleteUntrackedNestedRepositories: true],[ class:CleanBeforeCheckout,deleteUntrackedNestedRepositories:true],[class: ‘CloneOption’, shallow: true, depth: 1, honorRefspec:true], [ c l a s s : ′ R e l a t i v e T a r g e t D i r e c t o r y ′ , r e l a t i v e T a r g e t D i r : " class: 'RelativeTargetDirectory', relativeTargetDir: " class:RelativeTargetDirectory,relativeTargetDir:"{fc}”]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: ‘4ce8a484-4afc-4414-a0fd-e650105daba6’, url: “ssh://git@174.34.48.189:8022/PSW_Automation/${Project_Name}.git”]]])

  • 10
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值