jenkins使用gitlab标签发布

关于jenkins git parameter使用gitlab标签发布和分支发布的用法

手动配置的我就不说了,点点点就行,主要是说一下在pipeline里如何使用

通过分支拉取gitlab仓库代码

复制代码
pipeline {
  agent any
  environment {

  }
  parameters {
  gitParameter(branch: '', branchFilter: '.*', defaultValue: '', description: 'Branch for build and deploy', name: 'branch', quickFilterEnabled: false, selectedValue: 'NONE', sortMode: 'NONE', tagFilter: '*', type: 'PT_BRANCH')
  }
  stages {
    stage(pull code) {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: '${branch}']], extensions: [], userRemoteConfigs: [[credentialsId: 'gitlab_auth', url: 'git@10.1.60.114:gitlab-instance-c484dcfc/nodejs.git']]])
      }
    }
  }
}

在pipeline配置git parameter后在Jenkins的项目配置中会自动生成以下配置

通过标签拉取gitlab仓库代码

复制代码
pipeline {
  agent any
  environment {

  }
  parameters {
  gitParameter(branch: '', branchFilter: '.*', defaultValue: '', description: 'Branch for build and deploy', name: 'tag', quickFilterEnabled: false, selectedValue: 'NONE', sortMode: 'NONE', tagFilter: '*', type: 'PT_TAG')
  }
  stages {
    stage(pull code) {
      steps {
        checkout([$class: 'GitSCM', branches: [[name: '${tag}']], extensions: [], userRemoteConfigs: [[credentialsId: 'gitlab_auth', url: 'git@10.1.60.114:gitlab-instance-c484dcfc/nodejs.git']]])
      }
    }
  }
}

在pipeline配置git parameter后在Jenkins的项目配置中会自动生成以下配置

注意,通过标签拉取代码是没有分支信息的,不要使用命令去输出分支的信息,不然会报错

以上pipeline配置主要注意的是,type需要配置对,分支使用 PT_BRANCH,标签使用PT_TAG

相关推荐
wanhengidc10 分钟前
云手机 多端互通 科技
运维·服务器·科技·游戏·智能手机
init_236111 分钟前
【BGP入门专题-3】bgp路由传递规则与路由属性1
运维·网络
弓弧名家_玄真君18 分钟前
Ubuntu 20.04.3 LTS 安装vnc (Xfce4 + Xvfb)
linux·运维·ubuntu
骥龙1 小时前
5.14、AI安全运维体系:构建企业级的“安全超脑”
运维·人工智能·安全
源梦想1 小时前
机甲恐龙动作冒险网页小游戏Linux部署教程
linux·运维·服务器
该用户已不存在1 小时前
Let’s Encrypt 证书有效期将缩至 45 天,运维天都塌了
运维·https·自动化运维
yiyeguzhou1002 小时前
论文解读:Overcoming the IOTLB wall for multi-100-Gbps Linux-based networking
linux·运维·服务器
妄想出头的工业炼药师2 小时前
cuda如何安装卸载
linux·运维·服务器
泡沫·2 小时前
3.sed 使用手册
运维
WangLanguager2 小时前
SVD介绍和代码示例
运维