-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpipeline-go.groovy
174 lines (164 loc) · 6.2 KB
/
pipeline-go.groovy
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!groovy
pipeline {
agent none
environment{
MAJOR_VERSION = 1
}
options {
buildDiscarder(logRotator(numToKeepStr:'5', artifactNumToKeepStr: '3'))
}
//TODO - TF stages; get source for this infra (pull)
//Build the environment
//packer image with caddy installed and configured via ansible
//Deploy image
stages{
stage('CHECK-UPDATE - Check/Update IaaC tools'){
agent any
steps{
script{
//def tfexit = sh returnStatus: true, script: 'terraform --version'
//echo "return code TF: ${tfexit}"
def tfout = sh returnStdout: true, script: 'terraform --version'
echo "tf output: ${tfout}"
}
}
}
stage('GET LATEST - Get Latest From Caddy Repo'){
agent any
environment{
GOPATH="${env.WORKSPACE + '/go'}"
}
steps{
echo "Go Get Caddy code"
sh "go get -u github.com/mholt/caddy/caddy"
sh "go get -u github.com/caddyserver/builds"
}
}
stage('BUILD - Build Caddy Web Server'){
agent any
environment{
GOPATH="${env.WORKSPACE + '/go'}"
}
steps{
echo "Build Caddy web server binary"
//echo "gopath ${env.GOPATH}"
//echo "path ${env.PATH}"
sh 'cd "${GOPATH}"/src/github.com/mholt/caddy/caddy/ && go build && ls -alh | grep "caddy"'
}
}
// stage('GIT INFORMATION'){
// agent any
// steps{
// echo "My branch name: ${env.BRANCH_NAME}"
// script {
// def myLib = new thenuclei.git.gitStuff();
// echo "My Commit: ${myLib.gitCommit("${env.WORKSPACE}/.git")}"
// }
// }
// }
// stage('UNIT TESTS'){
// agent {
// label 'apache'
// }
// steps {
// sh 'ant -f test.xml -v'
// junit 'reports/result.xml'
// }
// }
// stage('BUILD'){
// agent {
// label 'apache'
// }
// steps {
// sh 'ant -f build.xml -v'
// }
// post{
// success {
// archiveArtifacts artifacts: 'dist/*.jar', fingerprint: true
// }
// }
// }
// stage('DEPLOY'){
// agent {
// label 'apache'
// }
// steps {
// sh "if ![ -d '/var/www/html/rectangles/all/${env.BRANCH_NAME}' ]; then mkdir /var/www/html/rectangles/all/${env.BRANCH_NAME}; fi"
// sh "cp dist/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/all/${env.BRANCH_NAME}"
// }
// }
// stage('CentOS RUN'){
// agent {
// label 'CentOS'
// }
// steps{
// sh "wget http://jenkins.thenuclei.org/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar"
// sh "java -jar rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar 3 4"
// }
// }
// stage('Debian/Ubuntu RUN'){
// agent {
// docker 'openjdk:8u141-jre'
// }
// steps{
// sh "wget http://jenkins.thenuclei.org/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar"
// sh "/usr/bin/java -jar rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar 3 4"
// }
// }
// stage('PROMOTE TO GREEN'){
// agent {
// label 'apache'
// }
// when {
// branch 'master'
// }
// steps {
// sh "cp /var/www/html/rectangles/all/${env.BRANCH_NAME}/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar /var/www/html/rectangles/green/rectangle_${env.MAJOR_VERSION}.${env.BUILD_NUMBER}.jar"
// }
// }
// stage('PROMOTE DEV BRANCH TO MASTER'){
// agent {
// label 'apache'
// }
// when {
// branch 'development'
// }
// steps {
// echo "Stashing any local changes"
// sh "git stash"
// echo "Checking out development"
// sh "git checkout development"
// echo "Checking out the master"
// sh "git pull origin"
// sh "git checkout master"
// echo "Merging dev into master"
// sh "git merge development"
// echo "Pushing to origin master"
// sh "git push origin master"
// echo "Tagging the release"
// sh "git tag rectangle-${env.MAJOR_VERSION}.${env.BUILD_NUMBER}"
// sh "git push origin rectangle-${env.MAJOR_VERSION}.${env.BUILD_NUMBER}"
// }
// post{
// success {
// emailext(
// subject: "${env.JOB_NAME} [${env.BUILD_NUMBER}] Development Promoted To Master!",
// body: """<p>'${env.JOB_NAME} [${env.BUILD_NUMBER}]' Development Promoted To Master!":</p>
// <p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
// to: "[email protected]"
// )
// }
// }
// }
}
//post{
// failure {
// emailext(
// subject: "${env.JOB_NAME} [${env.BUILD_NUMBER}] failed!",
// body: """<p>'${env.JOB_NAME} [${env.BUILD_NUMBER}]' Failed!":</p>
// <p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>""",
// to: "[email protected]"
// )
//}
//}
}