package org.devops
def test_success() {
sh '''
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key='$webhook'' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "#### 构建成功 ✅:'$name'项目!
>### 持续时间:'$times'
>### 任务:#'$task'"
}
}'
'''
}
def test_failure(){
sh '''
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key='$webhook'' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "#### 构建失败 ❌'$name'项目!
>### 持续时间:'$times'
>### 任务:#'$task'"
}
}'
'''
}
@Library ("jr-shared-library") _
def wxput = new org.devops.wxput()
pipeline {
agent any
environment {
name="wxput_test"
times="${currentBuild.duration}"
task="${BUILD_ID}"
logs="${ChangeLog}"
webhook="e20f4185-817c-4838-b92e-c3fa6f9c3f5"
}
stages {
stage('Hello') {
steps {
echo 'Hello World'
}
}
}
post {
success {
script{
wxput.test_success()
}
}
failure {
script{
wxput.test_failure()
}
}
}
}
@Library ("jr-shared-library") _
def docker_test_bui = new org.devops.docker_test_bui()
def deploy_test = new org.devops.deploy_test()
def wxput = new org.devops.wxput()
pipeline {
environment {
name="salary-manager"
image="/libary/jr-prod-01:${name}$BUILD_ID"
times="${currentBuild.duration}"
task="${BUILD_ID}"
logs="${ChangeLog}"
webhook="e20f4185-817c-4838-b92e-c3fa6f9c3f5"
}
agent {
kubernetes {
inheritFrom 'maven-test'
}
}
options{
timestamps ()
disableConcurrentBuilds ()
buildDiscarder(logRotator(numToKeepStr: '10'))
}
stages {
stage('Get Code') {
steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 'vip', url: 'https://wwwq.q..ocm/SS-salary/alary-manager.git']]])
}
}
stage('Java-build') {
steps {
container('maven36'){
sh 'mvn install -DskipTests'
}
}
}
stage('Docker-build') {
steps {
container('docker'){
script {
docker_test_bui.docker_bui()
}
}
}
}
stage('Deploy....') {
steps {
container('kubectl'){
script {
deploy_test.test_kue()
}
}
}
}
}
post {
success {
script{
wxput.test_success()
}
}
failure {
script{
wxput.test_failure()
}
}
}
}