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

相关推荐
Otaku love travel1 小时前
实施运维文档
运维·windows·python
basketball6162 小时前
Linux C 管道文件操作
linux·运维·c语言
浩浩测试一下2 小时前
Windows 与 Linux 内核安全及 Metasploit/LinEnum 在渗透测试中的综合应用
linux·运维·windows·web安全·网络安全·系统安全·安全架构
将心ONE3 小时前
使用 lstrip() 和 rstrip() 方法
运维·服务器
G_whang3 小时前
centos7 安装jenkins
运维·jenkins
言之。4 小时前
借助ssh实现web服务的安全验证
运维·安全·ssh
Two_brushes.4 小时前
【linux网络】深入理解 TCP/UDP:从基础端口号到可靠传输机制全解析
linux·运维·服务器
FJW0208145 小时前
【Linux】系统引导修复
linux·运维·服务器
✧北辰٩(ˊωˋ*)و南冥✧5 小时前
nginx 负载均衡配置(加解决重复登录问题)
运维·nginx·负载均衡
设计师小聂!5 小时前
linux常用命令(一)
linux·运维·服务器