-
Notifications
You must be signed in to change notification settings - Fork 11
/
Jenkinsfile
81 lines (73 loc) · 2.15 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
69
70
71
72
73
74
75
76
77
78
79
80
81
// Declarative Pipeline
pipeline {
// Set up the docker agent the jenkins slave will run on
// agent { docker { image 'python:3.8' } }
agent none
environment {
VERSION_NO = '1.0'
repo = "bchewy/eti_game"
registryCredential = 'dockerhub'
dockerImg = ''
}
stages {
stage('Initialize'){
agent { dockerfile true }
steps{
script{
def dockerHome = tool 'myDocker'
env.PATH = "${dockerHome}/bin:${env.PATH}"
}
}
}
stage('Build') {
agent { dockerfile true }
steps {
echo 'Building..'
sh 'python --version'
sh 'python3 py_compileCheck.py'
}
}
stage('Test') {
agent { dockerfile true }
steps {
echo 'Testing..'
// Run pytest and check coverage of explicit files to 90% Coverage./
sh 'pytest --cov --cov-fail-under 35 --junitxml=coverage.xml'
}
post {
always {
junit 'coverage.xml'
}
}
}
stage('Deploy') {
agent { label 'master' }
steps {
echo 'Deploying....'
// Push to dockerhub image repository with tags per mergeid/featurebranch or etc.
script{
dockerImg = docker.build repo+":$BUILD_NUMBER"
docker.withRegistry( '', registryCredential ) {
dockerImg.push()
}
sh 'docker rmi $repo:$BUILD_NUMBER'
}
}
}
}
}
// Scripted Pipeline
// node{
// Stage 'Checkout'
// echo 'Checkout Stage'
// checkout scm
// Stage 'Build'
// echo 'Building Stage'
// sh 'python --version'
// sh 'python3 Game/py_compileCheck.py'
// Stage 'Test'
// echo 'Test Stage'
// //Pytest here
// Stage 'Deploy'
// echo 'Test Stage'
// }