jenkins触发器
安装插件Generic Webhook Trigger配置触发器获取分支VariablerefExpression$.ref获取git仓库地址VariableprojectExpression$.project.http_url设置tokengitlab配置触发触发地址https://jenkins.uat.wuxingge.com.cn/generic-webhook-trigger/invok
·
参考
https://plugins.jenkins.io/generic-webhook-trigger/
安装插件
Generic Webhook Trigger
配置触发器

获取分支
Variable
ref
Expression
$.ref
获取git仓库地址

Variable
project
Expression
$.project.http_url
设置token

gitlab配置触发
触发地址
https://jenkins.uat.wuxingge.com.cn/generic-webhook-trigger/invoke?token=trigger

配置流水线
def registry = "harbor.test.wuxingge.com.cn"
def app_name = "$JOB_NAME"
def jenkins_slave_image = "${registry}/uat/jenkins-slave-maven-centos7:v1"
def docker_registry_auth = "harbor"
def git_auth = "gitlab-devops"
def k8s_auth = "kube-config-rancher"
def k8s_cloud_name = "rancher-uat"
def label_name = "jenkins-slave-${app_name}"
podTemplate(label: "$label_name", cloud: "$k8s_cloud_name", containers: [
containerTemplate(
name: 'jnlp',
image: "${jenkins_slave_image}"
),
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock'),
hostPathVolume(mountPath: '/usr/bin/docker', hostPath: '/usr/bin/docker'),
hostPathVolume(mountPath: '/home/jenkins/.m2', hostPath: '/root/nexusm2/.m2'),
hostPathVolume(mountPath: '/home/jenkins/dockerfile-yaml', hostPath: '/dockerfile_yaml')
],
)
{
node("$label_name"){
stage('拉取代码'){
def arr = ref.split("refs/heads/") as List
def currentBranch = arr[1]
def git_address = project
checkout([$class: 'GitSCM', branches: [[name: "${currentBranch}"]], userRemoteConfigs: [[credentialsId: "${git_auth}", url: "${git_address}"]]])
}
stage('test'){
sh """
echo $project
"""
}
}
}
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)