-
Notifications
You must be signed in to change notification settings - Fork 17
/
Jenkinsfile
47 lines (44 loc) · 1.55 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
pipeline {
agent any
environment {
// Replace the <tags> below with your values.
FALCON_CLIENT_SECRET = credentials('FALCON_CLIENT_SECRET')
FALCON_CLIENT_ID = credentials('FALCON_CLIENT_ID')
BUILD_DIR = '.'
CONTAINER_REPO = '<repo_name>'
CONTAINER_TAG = "${BUILD_NUMBER}"
FALCON_CLOUD_REGION = 'us-2'
//SCORE = 500
}
stages {
stage('BuildImage') {
// Build the docker image using the docker file in the current directory
steps{
sh "docker build -t $CONTAINER_REPO:$CONTAINER_TAG $BUILD_DIR"
}
}
stage('ScanImage') {
// Scan the image using Falcon ImageScan API
steps{
sh '''
if [ ! -d container-image-scan ] ; then
git clone https://github.com/crowdstrike/container-image-scan
fi
pip3 install docker crowdstrike-falconpy
python3 container-image-scan/cs_scanimage.py
'''
}
}
stage('PushImage') {
// Push the container image
steps{
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId:'dockerhub', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) {
sh '''
echo $PASSWORD | docker login -u $USERNAME --password-stdin
docker push $CONTAINER_REPO:$CONTAINER_TAG
'''
}
}
}
}
}