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

相关推荐
AmosTian1 小时前
【系统与工具】Linux——Linux简介、安装、简单使用
linux·运维·服务器
YC运维2 小时前
RIP实验以及核心原理
运维·网络·智能路由器
leo__5204 小时前
自动化运维:使用Ansible简化日常任务
运维·自动化·ansible
霖004 小时前
C++学习笔记三
运维·开发语言·c++·笔记·学习·fpga开发
CodeWithMe4 小时前
【Note】《Kafka: The Definitive Guide》 第九章:Kafka 管理与运维实战
运维·分布式·kafka
bug攻城狮5 小时前
Alloy VS Promtail:基于 Loki 的日志采集架构对比与选型指南
运维·架构·grafana·数据可视化
CodeWithMe6 小时前
【Note】《深入理解Linux内核》 第十九章:深入理解 Linux 进程通信机制
linux·运维·php
睿思达DBA_WGX6 小时前
由 DB_FILES 参数导致的 dg 服务器无法同步问题
运维·数据库·oracle
vvw&7 小时前
Linux 中的 .bashrc 是什么?配置详解
linux·运维·服务器·chrome·后端·ubuntu·centos