forked from shadowshot-x/micro-product-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
68 lines (65 loc) · 2.13 KB
/
Jenkinsfile
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
pipeline {
agent any
tools {
go 'go1.17'
}
environment {
GO117MODULE = 'on'
CGO_ENABLED = 0
GOPATH = "${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}"
}
stages {
stage("check-git-secrets") {
steps {
echo 'Checking Secrets'
sh 'rm trufflehog || true'
sh 'docker run gesellix/trufflehog --json https://github.com/ssk199441/micro-product-go.git > trufflehog'
sh 'cat trufflehog'
}
}
stage("source-Composition-analysis") {
steps {
echo 'Source Composition Analysis Started'
sh 'pwd'
sh 'go list -json -deps | docker run --rm -i sonatypecommunity/nancy:latest sleuth'
}
}
stage("unit-test") {
steps {
echo 'UNIT TEST EXECUTION STARTED'
sh 'make unit-tests'
}
}
stage("functional-test") {
steps {
echo 'FUNCTIONAL TEST EXECUTION STARTED'
sh 'make functional-tests'
}
}
stage("build") {
steps {
echo 'BUILD EXECUTION STARTED'
sh 'go version'
sh 'go get ./...'
sh 'docker build . -t ssk1994/product-go-micro'
}
}
stage("scan-docker") {
steps {
echo 'Docker Image Scanning Started'
sh 'git clone https://github.com/docker/docker-bench-security.git'
sh 'cd docker-bench-security'
sh 'docker-compose run --rm docker-bench-security'
}
}
stage('Docker Push') {
agent any
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'dockerhubPassword', usernameVariable: 'dockerhubUser')]) {
sh "docker login -u ${env.dockerhubUser} -p ${env.dockerhubPassword}"
sh 'docker push ssk1994/product-go-micro'
}
}
}
}
}