本文主要是介绍使用可接受gitlab参数的插件配置webhook,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
jenkins配置
- 安装Generic Webhook Trigger
- 配置远程触发令牌
勾选Print post content和Print contributed variables用于打印值
配置gitlab
- 选择新增webhook
配置webhook
http://JENKINS_URL/generic-webhook-trigger/invoke,将JENKINS_URL修改成自己的jenkins地址
- 先保存再测试
解析jenkins接收到的事件json里边的参数
jenkins配置
流水线配置方法
#!groovy
/*
演示mvn集成到jenkins 流水线中的用法
*/
string buildShell = "$BUILD_SHELL"
pipeline{agent {node {label "$CI_NODE"}}stages{stage("mvn build"){steps{if ("${runOpts}" == "GitlabPush"){env.runOpts = "GitlabPush"branch = branch - "refs/heads/"currentBuild.description = "Trigger by ${url} ${branch}"}script{mvnHome = tool "MVN"sh "$mvnHome/bin/mvn ${buildShell}"}}}stage("gradle build"){steps{script{gradleHome = tool "GRADLE"sh "$gradleHome/bin/gradle ${buildShell}"}}}stage("ant build"){steps{script{antHome = tool "ANT"sh "$antHome/bin/ant ${buildShell}"}}}}
}
参数解析效果:
参考文档;https://www.cnblogs.com/louis2008/p/jenkins-gitlab.html
视频:https://www.bilibili.com/video/BV11P4y1m7nG?p=19&vd_source=9bfdc5be7a49dd0810a8319a82a055d3
这篇关于使用可接受gitlab参数的插件配置webhook的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!