forked from scribe-security/jenkins-pki-example
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
158 lines (143 loc) · 5.92 KB
/
Copy pathJenkinsfile
File metadata and controls
158 lines (143 loc) · 5.92 KB
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
node {
withEnv([
"PATH=./temp/bin:$PATH",
"APP_NAME=PKI-Sign-demo-project",
"APP_VERSION=1.1.3",
"AUTHOR_NAME=John-Smith",
"AUTHOR_EMAIL=jhon@thiscompany.com",
"AUTHOR_PHONE=555-8426157",
"SUPPLIER_NAME=Scribe-Security",
"SUPPLIER_URL=www.scribesecurity.com",
"SUPPLIER_EMAIL=info@scribesecurity.com",
"SUPPLIER_PHONE=001-001-0011",
"PRIVATE_KEY=xxx",
"SIGNING_CERT=yyy",
"CA_CERT=xxx",
"DOCKERHUB_USERNAME=scribesecurity"
])
{
stage('install') {
cleanWs()
sh 'curl -sSfL https://get.scribesecurity.com/install.sh | sh -s -- -b ./temp/bin'
}
stage('checkout') {
withCredentials([
string(credentialsId: 'Dockerhub_pat', variable: 'DOCKERHUB_PAT') ])
{
sh 'git clone -b main --single-branch https://github.com/scribe-security/jenkins-pki-example.git'
sh 'cd jenkins-pki-example; docker build -t pki-test:latest -f ./orig-Dockerfile .'
sh 'echo $DOCKERHUB_PAT|docker login -u $DOCKERHUB_USERNAME --password-stdin'
sh 'docker image tag pki-test:latest scribesecurity/pki-test:latest'
sh 'docker push scribesecurity/pki-test:latest'
}
}
stage('git-commit-sbom') {
withCredentials([
usernamePassword(credentialsId: 'scribe-production-auth-id', usernameVariable: 'SCRIBE_CLIENT_ID', passwordVariable: 'SCRIBE_CLIENT_SECRET'),
file(credentialsId: 'key-file', variable: 'KEY_FILE'),
file(credentialsId: 'sig-cert-file', variable: 'SIG_CERT_FILE'),
file(credentialsId: 'ca-cert-file', variable: 'CA_CERT_FILE')
])
{
sh '''
PRIVATE_KEY=$(cat $KEY_FILE)
SIGNING_CERT=$(cat $SIG_CERT_FILE)
CA_CERT=$(cat $CA_CERT_FILE)
valint bom git:jenkins-pki-example/. \
--components packages,files,dep \
--context-type jenkins \
--format attest\
--attest.default x509 \
--ca $CA_CERT_FILE \
--cert $SIG_CERT_FILE \
--key $KEY_FILE \
--output-directory ./scribe/valint \
-E -P $SCRIBE_CLIENT_SECRET \
--product-key $APP_NAME \
--author-name $AUTHOR_NAME --author-email AUTHOR_EMAIL --author-phone $AUTHOR_PHONE \
--supplier-name $SUPPLIER_NAME --supplier-url $SUPPLIER_URL --supplier-email $SUPPLIER_EMAIL \
--supplier-phone $SUPPLIER_PHONE \
--label is_git_commit \
-f '''
}
}
stage('bom-git') {
withCredentials([
usernamePassword(credentialsId: 'scribe-production-auth-id', usernameVariable: 'SCRIBE_CLIENT_ID', passwordVariable: 'SCRIBE_CLIENT_SECRET'),
file(credentialsId: 'key-file', variable: 'KEY_FILE'),
file(credentialsId: 'sig-cert-file', variable: 'SIG_CERT_FILE'),
file(credentialsId: 'ca-cert-file', variable: 'CA_CERT_FILE')
])
{
sh '''
valint bom git:jenkins-pki-example/. \
--components packages,files,dep \
--context-type jenkins \
--format attest\
--attest.default x509 \
--ca $CA_CERT_FILE \
--cert $SIG_CERT_FILE \
--key $KEY_FILE \
--output-directory ./scribe/valint \
-E -P $SCRIBE_CLIENT_SECRET \
--product-key $APP_NAME \
--author-name $AUTHOR_NAME --author-email AUTHOR_EMAIL --author-phone $AUTHOR_PHONE \
--supplier-name $SUPPLIER_NAME --supplier-url $SUPPLIER_URL --supplier-email $SUPPLIER_EMAIL \
--supplier-phone $SUPPLIER_PHONE \
-f '''
}
}
/* stage('provenance-image') {
withCredentials([
usernamePassword(credentialsId: 'scribe-production-auth-id', usernameVariable: 'SCRIBE_CLIENT_ID', passwordVariable: 'SCRIBE_CLIENT_SECRET'),
file(credentialsId: 'key-file', variable: 'KEY_FILE'),
file(credentialsId: 'sig-cert-file', variable: 'SIG_CERT_FILE'),
file(credentialsId: 'ca-cert-file', variable: 'CA_CERT_FILE')
])
{
sh '''
valint slsa pki-test:latest \
--components packages,files,dep \
--context-type jenkins \
--format attest\
--attest.default x509 \
--ca $CA_CERT_FILE \
--cert $SIG_CERT_FILE \
--key $KEY_FILE \
--output-directory ./scribe/valint \
-E -P $SCRIBE_CLIENT_SECRET \
--product-key $APP_NAME \
--author-name $AUTHOR_NAME --author-email AUTHOR_EMAIL --author-phone $AUTHOR_PHONE \
--supplier-name $SUPPLIER_NAME --supplier-url $SUPPLIER_URL --supplier-email $SUPPLIER_EMAIL \
--supplier-phone $SUPPLIER_PHONE \
-f '''
}
} */
stage('bom-image') {
withCredentials([
usernamePassword(credentialsId: 'scribe-production-auth-id', usernameVariable: 'SCRIBE_CLIENT_ID', passwordVariable: 'SCRIBE_CLIENT_SECRET'),
file(credentialsId: 'key-file', variable: 'KEY_FILE'),
file(credentialsId: 'sig-cert-file', variable: 'SIG_CERT_FILE'),
file(credentialsId: 'ca-cert-file', variable: 'CA_CERT_FILE')
])
{
sh '''
valint bom pki-test:latest \
--components packages,files,dep \
--context-type jenkins \
--format attest\
--attest.default x509 \
--ca $CA_CERT_FILE \
--cert $SIG_CERT_FILE \
--key $KEY_FILE \
--output-directory ./scribe/valint \
-E -P $SCRIBE_CLIENT_SECRET \
--product-key $APP_NAME \
--author-name $AUTHOR_NAME --author-email AUTHOR_EMAIL --author-phone $AUTHOR_PHONE \
--supplier-name $SUPPLIER_NAME --supplier-url $SUPPLIER_URL --supplier-email $SUPPLIER_EMAIL \
--supplier-phone $SUPPLIER_PHONE \
-f '''
}
}
}
}