forked from RitheeshBaradwaj/JenkinsPipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
93 lines (85 loc) · 2.88 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
82
83
84
85
86
87
88
89
90
91
92
93
pipeline {
agent any
stages {
stage('Clean Reports')
{
steps{
echo '********* Cleaning Workspace Stage Started **********'
bat 'rmdir /s /q test-reports'
echo '********* Cleaning Workspace Stage Finished **********'
}
}
stage('Build Stage') {
steps {
echo '********* Build Stage Started **********'
bat 'pip install -r requirements.txt'
bat 'pyinstaller --onefile app.py'
echo '********* Build Stage Finished **********'
}
}
stage('Testing Stage') {
steps {
echo '********* Test Stage Started **********'
bat 'python test.py'
echo '********* Test Stage Finished **********'
}
}
stage('Configure Artifactory'){
steps{
script {
echo '********* Configure Artifactory Started **********'
def userInput = input(
id: 'userInput', message: 'Enter password for Artifactory', parameters: [
[$class: 'TextParameterDefinition', defaultValue: 'password', description: 'Artifactory Password', name: 'password']])
bat 'jfrog rt c artifactory-demo --url=http://34.68.191.118:8081/artifactory --user=admin --password='+userInput
echo '********* Configure Artifactory Finished **********'
}
}
}
stage('Sanity check') {
steps {
input "Does the staging environment look ok?"
}
}
stage('Deployment Stage'){
steps{
input "Do you want to Deploy the application?"
echo '********* Deploy Stage Started **********'
timeout(time : 1, unit : 'MINUTES')
{
bat 'python app.py'
}
echo '********* Deploy Stage Finished **********'
}
}
}
post {
always {
echo 'We came to an end!'
archiveArtifacts artifacts: 'dist/*.exe', fingerprint: true
junit 'test-reports/*.xml'
script{
if(currentBuild.currentResult=='SUCCESS')
{
echo '********* Uploading to Artifactory is Started **********'
/*bat 'jfrog rt u "dist/*.exe" generic-local'*/
bat 'Powershell.exe -executionpolicy remotesigned -File build_script.ps1'
echo '********* Uploading Finished **********'
}
}
deleteDir()
}
success {
echo 'Build Successfull!!'
}
failure {
echo 'Sorry mate! build is Failed :('
}
unstable {
echo 'Run was marked as unstable'
}
changed {
echo 'Hey look at this, Pipeline state is changed.'
}
}
}