本文发布于Cylon的收藏册,转载请著名原文链接~

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def timestr() { 
    script {  
        return sh(script: 'date +%Y%m%d%H%M%S', returnStdout: true).trim()
    }
}

def dockerImage

pipeline{
    agent any
    
    environment {
        time = timestr()
        registry = "xxx.com/payapp-test"
        registryhub = "txhub.xxx.com"
        appName = "api"
    }
    
    options {
        timeout(time: 1, unit: 'HOURS')
        buildDiscarder(logRotator(numToKeepStr: '15'))
        disableConcurrentBuilds()
    }
    
    stages{
        
        stage("Pull Code"){
            steps{
                git branch: 'testing', credentialsId: '422fb2c7-4d58-440a-98a4-e242b66f3800', url: 'http://gitlab.fgry45iy.com:90/pay/payGateway.git'
            }
        }
        
        stage("Maven Package"){
            steps{
                withEnv(['PATH+EXTRA=/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/apache-maven-3.6.2/bin:/usr/local/maven/bin:/root/bin']) {
                    sh "mvn package"
                }
            }
        }
        
//         stage('Building Image') {
//             steps{
//                 script {
//                     dockerImage = docker.build( registry + "/" + appName + ":$BUILD_NUMBER")
//                 }
//             }
//         }
        
//         stage('Push Images To Registry') {
//             steps {
//                 script {
//                      dockerImage.push()
//                 }
//             }
//         }
        
//         stage('update') {
//             steps {
//                 sh """
//               curl -k --cert /root/ca/ca.crt --key /root/ca/ca.key  -X PUT -H  'Content-Type: application/yaml' --data "
// apiVersion: apps/v1
// kind: Deployment
// metadata:
//   name: tyapi-api-deploy
//   namespace: pay
// spec:
//   replicas: 2
//   selector:
//     matchLabels:
//       app: pay-api
//   template:
//     metadata:
//       labels:
//         app: pay-api
//     spec:
//       containers:
//       - name: pay-jv2-api
//         image: txhub.99xyp.com/payapp-test/api:$BUILD_NUMBER
//         ports:
//         - name: payapi
//           containerPort: 8081
// " https://47.156.81.22:6443/apis/apps/v1/namespaces/pay/deployments/tyapi-api-deploy
//                 """
//             }
//         }
    }
    
//     post {
//         cleanup {
//             echo 'I have finished, delete dir'
//             deleteDir()
//         }
//     }
}

本文发布于Cylon的收藏册,转载请著名原文链接~

链接:https://www.oomkill.com/2018/11/jenkins-docker/

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」 许可协议进行许可。