-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
77 lines (71 loc) · 2.07 KB
/
Jenkinsfile
File metadata and controls
77 lines (71 loc) · 2.07 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
#!/usr/bin/env groovy
def archive() {
list = ["module.txt", "README.md", "logo.png", "cover.png"]
changed = false
list.each { file ->
equals = ""
if(fileExists("output/$file")) {
equals = sh "diff output/$file artifacts/output/$file"
if(equals == null) {
println("$file is same as old artifact.")
} else {
println("$file is not same.")
changed = true
}
} else {
println("$file doesn't exists.")
if(fileExists("artifacts/output/$file")) {
changed = true
}
}
}
if(changed == true) {
println("Some files were updated. Archiving new meta-data...")
archiveArtifacts artifacts: 'output/*.*', fingerprint: true
} else {
println("None of the required files were updated. Skipping archiving meta-data...")
}
}
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
checkout scm
// Rest Build Logic
}
}
stage('Gather Data') {
steps {
sh "mkdir -p output"
sh "./groovyw scrape.groovy"
}
}
stage('Check Data') {
when {
expression { currentBuild.previousBuild }
}
steps {
sh "mkdir -p artifacts"
script{
try{
copyArtifacts(projectName: currentBuild.projectName,
target: "artifacts",
selector: lastSuccessful())
archive()
} catch(err) {
println("$err")
archiveArtifacts artifacts: 'output/*.*', fingerprint: true
}
}
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
// Deploy Logic
}
}
}
}