首页 > 其他分享 >Jenkins: Generic Webhook Trigger

Jenkins: Generic Webhook Trigger

时间:2022-11-09 20:57:36浏览次数:35  
标签:src git name Generic -- Trigger key regexpFilter Jenkins

 

GitHub:

Payload URL:

 https://jenkins-new.jam.only.sap/generic-webhook-trigger/invoke?token=resurrect&jobQuietPeriod=1

 

 

 

 

 

 

Pipeline:

pipeline {
    agent {
        label 'translation'
    }

    environment {
        param1 = 'value1'
    }

    triggers {
        GenericTrigger(
            genericVariables: [
                [defaultValue: '', key: 'action', regexpFilter: '', value: '$.action'],
                [defaultValue: '', key: 'src_full_name', regexpFilter: '', value: '$.pull_request.head.repo.full_name'],
                [defaultValue: '', key: 'user', regexpFilter: '', value: '$.pull_request.user.login'],
                [defaultValue: '', key: 'src_branch', regexpFilter: '', value: '$.pull_request.head.ref'],
                [defaultValue: '', key: 'src_repo_name', regexpFilter: '', value: '$.pull_request.head.repo.name'],
                [defaultValue: '', key: 'label', regexpFilter: '', value: '$.pull_request.head.label'],
                [defaultValue: '', key: 'webhook', regexpFilter: '', value: '$'],
                [defaultValue: '', key: 'src', regexpFilter: '[^0-9]', value: '$.pull_request.head.repo.full_name']
            ],
            overrideQuietPeriod: true, printContributedVariables: true, printPostContent: true, causeString: '$user $src_full_name $src_branch',
            regexpFilterExpression: '^opened-service-tip-git/.*$', regexpFilterText: '$action-$src_full_name', token: '', tokenCredentialId: 'translation-pr-token'
        )
    }

    options {
        retry 1
        timestamps()
        quietPeriod 2
        skipDefaultCheckout true
        disableConcurrentBuilds()
        timeout(time: 5, unit: 'MINUTES')
        buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '100', numToKeepStr: '10')

    }

    stages {
        stage('Clean Workspace') {
            steps {
                script {
                    cleanWs notFailBuild: true
                    def webhook = readJSON(text: "${webhook}")
                }
            }
        }
        stage('Checkout') {
            steps {
                script {
                    checkout([$class: 'GitSCM', branches: [[name: ':^(?!(origin/prefix)).*']], extensions: [], userRemoteConfigs: [[credentialsId: 'jambot-key', url: '[email protected]:sap-jam/translation-integration.git']]])
                }
            }
        }
        stage('Operate') {
            steps {
                script {
                    sh 'printenv'
                    sh 'ruby -rlogger -rfileutils -e "puts 555555555555555555555"'
                    sh 'pwd;ls -al'
                    withCredentials([usernamePassword(credentialsId: 'translation_token', passwordVariable: 'translation_git_token', usernameVariable: 'translation_git_username')]) {
                        sh '''
                        git clone --quiet --progress --jobs 5 --depth 1 --branch $src_branch https://$translation_git_username:[email protected]/service-tip-git/ct
                       
                        ls -al
                        ruby PostProcess.rb
                        ls -al ct
                        
                        cd ct
                        git branch -alvv
                        git checkout --progress $src_branch
                        git commit -am 'post processing with jenkins pipeline'
                        git push --quiet --all --progress --atomic
                        '''
                    }
                }

            }
        }
    }
}

 

 

Jenkins:

 

标签:src,git,name,Generic,--,Trigger,key,regexpFilter,Jenkins
From: https://www.cnblogs.com/dissipate/p/16875133.html

相关文章

  • Docker学习笔记五:Docker安装Jenkins
    一、安装准备1、安装软件JDKMavenGit(不需要单独安装,直接通过Jenkins安装Git插件即可)2、拉取docker镜像命令:dockerpulljenkins/jenkins二、开始安装1、安......
  • 4.jenkins安装配置升级
    1.什么是jenkinsjenkins是一个开源提供友好操作界面的持续集成的工具,由java开发而成。jenkins是一个调度平台,本身不处理任何事情,都是借由插件完成所有的工作2.为什么使......
  • Docker 安装 Jenkins
    一、Docker介绍1、什么是dockerDocker容器是一个开源的应用容器引擎,让开发者可以以统一的方式打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何安装了docke......
  • 快速搭建Jenkins集群
    欢迎访问我的GitHub这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos关于Jenkins集群在Jenkins上同时执行多个任务时,单机性能可能达......
  • jenkins 发版获取镜像仓库中tag
    一、安装阿里云linux客户端工具选择官网下载地址#wgetwgethttps://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz#tar-xfaliyun-cli-linux-latest-am......
  • docker 安装jenkins
    1.dockerpulljenkins/jenkins 2.创建Jenkins挂载目录并授权权限(我们在服务器上先创建一个jenkins工作目录/var/jenkins_mount,赋予相应权限,稍后我们将jenkins容器目录......
  • Generics in Python
    泛型(Generics)https://www.geeksforgeeks.org/generics-in-java/一般类的定义,其引用类是要在其代码中明确指定的但是对于一些上层公共逻辑,其期望可以应用到若干引用类中......
  • 使用插件实现Jenkins参数化构建
     一、插件安装1、打开插件管理,在此界面可以安装插件 二、参数化1、在“可选插件”中查找如下两个插件然后安装,安装后重启JenkinsBuildWithParameters输入框式的参数Per......
  • Jenkins安装和自动化部署
    1、Jenkins安装机器安装要求可以参考官网https://www.jenkins.io  2、下载jenkins的war包上传到linux上部署    3、安装jdk、git、maven3.1、安装jdk......
  • Jenkins Pipeline SSH Publisher 环境变量、参数引用 要用双引号
    JenkinsPipelineSSHPublisher环境变量、参数引用 要用双引号在Pipeline 脚本中,如果要使用变量,就必须使用“ 双引号pipeline{agentanyenvironment......