forked from adobe/spectrum-css
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
122 lines (111 loc) · 4.63 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
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
pipeline {
agent any
environment {
PATH = "/apps/java/latest/bin:/usr/bin/node:$PATH"
SPECTRUM_GIT_REPO_PATH = "${BRANCH_NAME}/${GIT_PREVIOUS_SUCCESSFUL_COMMIT}/"
}
options {
lock resource: 'Lock to one build at a time'
}
stages {
stage('Show Environment') {
steps {
sh "env"
sh "node --version"
sh "npm --version"
}
}
stage('Install Dependencies') {
steps {
sh 'echo "@spectrum:registry=https://artifactory.corp.adobe.com:443/artifactory/api/npm/npm-spectrum-release/" >> ~/.npmrc'
sh 'echo "@a4u:registry=https://artifactory.corp.adobe.com:443/artifactory/api/npm/npm-a4u-release-local/" >> ~/.npmrc'
// install npm dependencies
sh "npm install"
}
}
stage('Get Previous Successful Commit Images') {
steps {
script {
env.MASTER_COMMIT_SHA =
sh (returnStdout: true, script: """
git ls-remote [email protected]:Spectrum/spectrum-css.git main | awk '{ print \$1 }' | tr -d '\n'
""")
env.PARENT_COMMIT_SHA =
sh (returnStdout: true, script: """
git rev-parse \$GIT_COMMIT^ | tr -d '\n'
""")
}
dir("spectrum-css-visual-reports") {
git url: "[email protected]:Spectrum/spectrum-css-visual-reports.git"
script {
// try to get the last previous successful git commit
if (fileExists("$BRANCH_NAME/$PARENT_COMMIT_SHA")) {
env.UPDATED_SPECTRUM_GIT_REPO_PATH =
sh (returnStdout: true, script: """
echo \$BRANCH_NAME/\$PARENT_COMMIT_SHA | tr -d '\n'
""")
} else {
echo "Previous commit doesn't exist - comparing against HEAD at MASTER"
env.UPDATED_SPECTRUM_GIT_REPO_PATH =
sh (returnStdout: true, script: """
echo main/\$MASTER_COMMIT_SHA | tr -d '\n'
""")
}
echo "$UPDATED_SPECTRUM_GIT_REPO_PATH/**"
stash name: "previous-spectrum-css-visual-tests", includes: "$UPDATED_SPECTRUM_GIT_REPO_PATH/**"
}
}
}
}
stage('Build Images') {
steps {
unstash "previous-spectrum-css-visual-tests"
sh "mkdir -p backstop_data/bitmaps_reference"
sh "mv $UPDATED_SPECTRUM_GIT_REPO_PATH/* backstop_data/bitmaps_reference"
sh "gulp build"
sh "gulp test"
}
}
stage('Test Images') {
steps {
// move folders around because of how backstopjs gens its file and what jenkins expects as an html report is weird
sh "mkdir backstop_data/html_report/bitmaps_reference"
sh "mkdir backstop_data/html_report/bitmaps_test"
sh "mv backstop_data/bitmaps_reference/* backstop_data/html_report/bitmaps_reference/"
sh "mv backstop_data/bitmaps_test/* backstop_data/html_report/bitmaps_test/"
sh ("""
sed -i -e "s@../bitmaps_reference@bitmaps_reference@g" backstop_data/html_report/config.js
""")
sh ("""
sed -i -e "s@../bitmaps_test@bitmaps_test@g" backstop_data/html_report/config.js
""")
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'backstop_data/html_report',
reportFiles: 'index.html',
reportName: 'Spectrum CSS Visual Regression Report'
]
sh "mkdir -p $BRANCH_NAME/$GIT_COMMIT"
sh "mv backstop_data/html_report/bitmaps_test/**/*.png $BRANCH_NAME/$GIT_COMMIT"
sh "ls -al $BRANCH_NAME/$GIT_COMMIT"
stash name: "spectrum-css-visual-tests", includes: "$BRANCH_NAME/$GIT_COMMIT/**", excludes: "**/failed_diff*"
}
}
stage('Upload Results to git.corp') {
steps {
dir("spectrum-css-visual-reports") {
unstash 'spectrum-css-visual-tests'
sh "git status"
sh "git add -A"
sh ("""
git commit -m "Visual report update"
git push origin main
""")
deleteDir()
}
}
}
}
}