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

相关推荐
我送炭你添花8 小时前
开源TR-069 ACS(自动配置服务器)GenieACS 的四个主要模块详细介绍
运维·服务器·开源
杭州杭州杭州8 小时前
Docker
运维·docker·容器
开开心心_Every8 小时前
Win10/Win11版本一键切换工具
linux·运维·服务器·edge·pdf·web3·共识算法
啟明起鸣8 小时前
【Nginx 网关开发】从源码分析 Nginx 的多进程启动原理
运维·nginx
怣509 小时前
Linux创意命令组合:让终端变得有趣又高效
linux·运维·服务器
啟明起鸣9 小时前
【Nginx 网关开发】上手 Nginx,简简单单启动一个静态 html 页面
运维·c语言·前端·nginx·html
Tinyundg9 小时前
Linux系统分区
linux·运维·服务器
要做一个小太阳9 小时前
华为Atlas 900 A3 SuperPoD 超节点网络架构
运维·服务器·网络·华为·架构
江畔何人初9 小时前
service发现
linux·运维·云原生
life码农9 小时前
Linux系统清空文件内容的几种方法
linux·运维·chrome