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

相关推荐
李狗蛋儿啊2 小时前
zero自动化框架搭建---Git安装详解
运维·git·自动化
小金的学习笔记2 小时前
如何在本地和服务器新建mysql用户和密码
运维·服务器·mysql
s_fox_3 小时前
nginx ngx_http_module(7) 指令详解
运维·nginx·http
EasyNVR3 小时前
EasyRTC智能硬件:实时畅联、沉浸互动、消音护航
运维·服务器·网络·安全·音视频·webrtc·p2p
CarryBest3 小时前
Jenkins 环境搭建---基于 Docker
运维·jenkins
若云止水4 小时前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_process_options
运维·nginx
s_fox_4 小时前
nginx ngx_http_module(9) 指令详解
运维·nginx·http
xing.yu.CTF6 小时前
Web入侵实战分析-常见web攻击类应急处置实验2
运维·服务器·windows·web安全·apache·php漏洞·phpstudy后门漏洞
我们的五年6 小时前
【Linux网络】TCP/IP地址的有机结合(有能力VS100%???),IP地址的介绍
linux·运维·网络·tcp/ip
[奋斗不止]6 小时前
Jenkins 节点 Node 概念
jenkins·jenkins node·jenkins节点node概念·jenkins 节点 node