Skip to content

Commit e357ddd

Browse files
Merge branch 'WORDSCLOUD-951' into 'master'
Wordscloud 951 See merge request words-cloud/words-cloud-node!4
2 parents bb1916e + c8cfe9a commit e357ddd

File tree

5 files changed

+213
-158
lines changed

5 files changed

+213
-158
lines changed

Jenkinsfile

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,70 @@
11
properties([
2-
parameters([string(defaultValue: 'master', description: 'the branch to build', name: 'branch', trim: true)])
2+
gitLabConnection('gitlab'),
3+
parameters([string(defaultValue: 'refs/heads/master', description: 'the branch to build', name: 'branch', trim: true)])
34
])
45

56
def runtests(dockerImageVersion)
67
{
78
dir(dockerImageVersion){
89
try {
9-
stage('checkout'){
10-
checkout([$class: 'GitSCM', branches: [[name: '*/' + params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-node.git']]])
11-
withCredentials([usernamePassword(credentialsId: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', passwordVariable: 'AppKey', usernameVariable: 'AppSid')]) {
12-
sh 'echo "{\\"AppSid\\": \\"$AppSid\\",\\"AppKey\\": \\"$AppKey\\"}" > testConfig.json'
13-
}
14-
}
10+
gitlabCommitStatus("checkout") {
11+
stage('checkout'){
12+
checkout([$class: 'GitSCM', branches: [[name: params.branch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-node.git']]])
13+
withCredentials([usernamePassword(credentialsId: '6839cbe8-39fa-40c0-86ce-90706f0bae5d', passwordVariable: 'AppKey', usernameVariable: 'AppSid')]) {
14+
sh 'echo "{\\"AppSid\\": \\"$AppSid\\",\\"AppKey\\": \\"$AppKey\\"}" > testConfig.json'
15+
}
16+
}
17+
}
1518

1619
docker.image('node:' + dockerImageVersion).inside{
17-
stage('build'){
18-
withEnv([
19-
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
20-
'npm_config_cache=npm-cache',
21-
/* set home to our current directory because other bower
22-
* nonsense breaks with HOME=/, e.g.:
23-
* EACCES: permission denied, mkdir '/.config'
24-
*/
25-
'HOME=.',
26-
]) {
27-
sh "npm install"
28-
29-
sh "npm run gulp build"
30-
if (params.branch == 'master'){
31-
sh "npm run lint"
32-
}
33-
}
34-
}
35-
36-
stage('tests'){
37-
try {
38-
sh "npm run test-jenkins"
39-
} finally {
40-
junit 'reports/**.xml'
20+
gitlabCommitStatus("build") {
21+
stage('build'){
22+
withEnv([
23+
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
24+
'npm_config_cache=npm-cache',
25+
/* set home to our current directory because other bower
26+
* nonsense breaks with HOME=/, e.g.:
27+
* EACCES: permission denied, mkdir '/.config'
28+
*/
29+
'HOME=.',
30+
]) {
31+
sh "npm install"
32+
33+
sh "npm run gulp build"
34+
if (params.branch == 'refs/heads/master'){
35+
sh "npm run lint"
36+
}
37+
}
4138
}
42-
}
43-
44-
stage('bdd-tests'){
45-
try {
46-
sh "npm run gulp cucumber"
47-
} finally {
48-
cucumber 'reports/**.json'
39+
}
40+
41+
gitlabCommitStatus("tests") {
42+
stage('tests'){
43+
try {
44+
sh "npm run test-jenkins"
45+
} finally {
46+
junit 'reports/**.xml'
47+
}
4948
}
50-
}
49+
}
50+
51+
gitlabCommitStatus("bdd-tests") {
52+
stage('bdd-tests'){
53+
try {
54+
sh "npm run gulp cucumber"
55+
} finally {
56+
cucumber 'reports/**.json'
57+
}
58+
}
59+
}
5160
}
5261
} finally {
5362
deleteDir()
63+
sh 'docker system prune -f'
5464
}
5565
}
5666
}
5767

5868
node('words-linux') {
5969
runtests("latest")
60-
}
61-
node('words-linux') {
62-
runtests("8.16")
6370
}

JenkinsfileRelease

Lines changed: 133 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,85 @@
1+
properties([
2+
gitLabConnection('gitlab')
3+
])
4+
15
node('words-linux') {
26
try {
3-
stage('checkout'){
4-
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-node.git']]])
5-
6-
sh "git config user.email \"[email protected]\""
7-
sh "git config user.name \"jenkins\""
7+
gitlabCommitStatus("checkout") {
8+
stage('checkout'){
9+
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-node.git']]])
810

9-
withCredentials([usernamePassword(credentialsId: '361885ba-9425-4230-950e-0af201d90547', usernameVariable: 'gitUsername', passwordVariable: 'gitPass')]) {
10-
gitRepoUrl = "https://${gitUsername}:${gitPass}@git.auckland.dynabic.com/words-cloud/words-cloud-node.git"
11-
}
12-
}
11+
sh "git config user.email \"[email protected]\""
12+
sh "git config user.name \"jenkins\""
13+
14+
withCredentials([usernamePassword(credentialsId: '361885ba-9425-4230-950e-0af201d90547', usernameVariable: 'gitUsername', passwordVariable: 'gitPass')]) {
15+
gitRepoUrl = "https://${gitUsername}:${gitPass}@git.auckland.dynabic.com/words-cloud/words-cloud-node.git"
16+
}
17+
}
18+
}
1319

14-
docker.image('node:latest').inside{
15-
stage('build package'){
16-
withEnv([
17-
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
18-
'npm_config_cache=npm-cache',
19-
/* set home to our current directory because other bower
20-
* nonsense breaks with HOME=/, e.g.:
21-
* EACCES: permission denied, mkdir '/.config'
22-
*/
23-
'HOME=.',
24-
]) {
25-
sh "npm install"
26-
sh "npm run gulp buildRelease"
27-
packageName = sh(returnStdout: true, script: 'npm pack').trim()
28-
29-
}
30-
31-
stash name: "newPackage", includes: "${packageName}"
32-
}
20+
docker.image('node:latest').inside{
21+
gitlabCommitStatus("build package") {
22+
stage('build package'){
23+
withEnv([
24+
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
25+
'npm_config_cache=npm-cache',
26+
/* set home to our current directory because other bower
27+
* nonsense breaks with HOME=/, e.g.:
28+
* EACCES: permission denied, mkdir '/.config'
29+
*/
30+
'HOME=.',
31+
]) {
32+
sh "npm install"
33+
sh "npm run gulp buildRelease"
34+
packageName = sh(returnStdout: true, script: 'npm pack').trim()
35+
36+
}
37+
38+
stash name: "newPackage", includes: "${packageName}"
39+
}
40+
}
3341
}
3442

35-
stage('Merge master to testPackage'){
36-
sh "git checkout --merge testPackage"
37-
sh "git reset --hard origin/testPackage"
38-
sh "git merge --no-ff --allow-unrelated-histories origin/master"
39-
sh "git diff --name-status"
40-
sh 'git commit -am "Merged master branch to testPackage" || exit 0'
41-
sh "git push ${gitRepoUrl} testPackage"
42-
}
43+
gitlabCommitStatus("Merge master to testPackage") {
44+
stage('Merge master to testPackage'){
45+
sh "git checkout --merge testPackage"
46+
sh "git reset --hard origin/testPackage"
47+
sh "git merge --no-ff --allow-unrelated-histories origin/master"
48+
sh "git diff --name-status"
49+
sh 'git commit -am "Merged master branch to testPackage" || exit 0'
50+
sh "git push ${gitRepoUrl} testPackage"
51+
}
52+
}
4353

44-
stage('add reference to new package'){
45-
unstash 'newPackage'
46-
docker.image('node:latest').inside{
47-
withEnv([
48-
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
49-
'npm_config_cache=npm-cache',
50-
/* set home to our current directory because other bower
51-
* nonsense breaks with HOME=/, e.g.:
52-
* EACCES: permission denied, mkdir '/.config'
53-
*/
54-
'HOME=.',
55-
]) {
56-
sh "npm uninstall asposewordscloud"
57-
sh "npm install ${packageName}"
58-
}
59-
}
60-
61-
sh "git diff --name-status"
62-
sh "git ls-files --others --exclude-standard"
63-
sh "git add -A"
64-
sh 'git commit -am "new version of package added to repository" || exit 0'
65-
sh "git push ${gitRepoUrl} testPackage"
66-
}
54+
gitlabCommitStatus("Merge master to testPackage") {
55+
stage('add reference to new package'){
56+
unstash 'newPackage'
57+
docker.image('node:latest').inside{
58+
withEnv([
59+
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
60+
'npm_config_cache=npm-cache',
61+
/* set home to our current directory because other bower
62+
* nonsense breaks with HOME=/, e.g.:
63+
* EACCES: permission denied, mkdir '/.config'
64+
*/
65+
'HOME=.',
66+
]) {
67+
sh "npm uninstall asposewordscloud"
68+
sh "npm install ${packageName}"
69+
}
70+
}
71+
72+
sh "git diff --name-status"
73+
sh "git ls-files --others --exclude-standard"
74+
sh "git add -A"
75+
sh 'git commit -am "new version of package added to repository" || exit 0'
76+
sh "git push ${gitRepoUrl} testPackage"
77+
}
78+
}
6779

6880
} finally {
6981
deleteDir()
82+
sh 'docker system prune -f'
7083
}
7184
}
7285

@@ -85,69 +98,77 @@ stage('wait for publish confirmation'){
8598

8699
node('words-linux') {
87100
try {
88-
stage('checkout again'){
89-
checkout([$class: 'GitSCM', branches: [[name: '*/testPackage']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-node.git']]])
90-
91-
sh "git config user.email \"[email protected]\""
92-
sh "git config user.name \"jenkins\""
93-
94-
withCredentials([usernamePassword(credentialsId: '361885ba-9425-4230-950e-0af201d90547', usernameVariable: 'gitUsername', passwordVariable: 'gitPass')]) {
95-
gitRepoUrl = "https://${gitUsername}:${gitPass}@git.auckland.dynabic.com/words-cloud/words-cloud-node.git"
96-
}
101+
gitlabCommitStatus("checkout again") {
102+
stage('checkout again'){
103+
checkout([$class: 'GitSCM', branches: [[name: '*/testPackage']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '361885ba-9425-4230-950e-0af201d90547', url: 'https://git.auckland.dynabic.com/words-cloud/words-cloud-node.git']]])
104+
105+
sh "git config user.email \"[email protected]\""
106+
sh "git config user.name \"jenkins\""
107+
108+
withCredentials([usernamePassword(credentialsId: '361885ba-9425-4230-950e-0af201d90547', usernameVariable: 'gitUsername', passwordVariable: 'gitPass')]) {
109+
gitRepoUrl = "https://${gitUsername}:${gitPass}@git.auckland.dynabic.com/words-cloud/words-cloud-node.git"
110+
}
97111

98-
sh "git checkout testPackage"
99-
sh "git reset --hard origin/testPackage"
100-
}
112+
sh "git checkout testPackage"
113+
sh "git reset --hard origin/testPackage"
114+
}
115+
}
101116

102-
stage('publish package'){
103-
docker.image('node:latest').inside{
104-
withEnv([
105-
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
106-
'npm_config_cache=npm-cache',
107-
/* set home to our current directory because other bower
108-
* nonsense breaks with HOME=/, e.g.:
109-
* EACCES: permission denied, mkdir '/.config'
110-
*/
111-
'HOME=.',
112-
]) {
113-
withCredentials([string(credentialsId: '19f0eab9-c600-4746-a4bd-724efd2102c8', variable: 'npmToken')]) {
114-
sh "echo //registry.npmjs.org/:_authToken=${npmToken} > .npmrc"
115-
sh "npm publish ${packageName}"
116-
}
117-
}
118-
}
117+
gitlabCommitStatus("publish package") {
118+
stage('publish package'){
119+
docker.image('node:latest').inside{
120+
withEnv([
121+
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
122+
'npm_config_cache=npm-cache',
123+
/* set home to our current directory because other bower
124+
* nonsense breaks with HOME=/, e.g.:
125+
* EACCES: permission denied, mkdir '/.config'
126+
*/
127+
'HOME=.',
128+
]) {
129+
withCredentials([string(credentialsId: '19f0eab9-c600-4746-a4bd-724efd2102c8', variable: 'npmToken')]) {
130+
sh "echo //registry.npmjs.org/:_authToken=${npmToken} > .npmrc"
131+
sh "npm publish ${packageName}"
132+
}
133+
}
134+
}
135+
}
119136
}
120137

121-
stage('change reference to published package'){
122-
docker.image('node:latest').inside{
123-
withEnv([
124-
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
125-
'npm_config_cache=npm-cache',
126-
/* set home to our current directory because other bower
127-
* nonsense breaks with HOME=/, e.g.:
128-
* EACCES: permission denied, mkdir '/.config'
129-
*/
130-
'HOME=.',
131-
]) {
132-
sh "npm uninstall asposewordscloud"
133-
sh "npm install asposewordscloud"
134-
}
135-
}
138+
gitlabCommitStatus("change reference to published package") {
139+
stage('change reference to published package'){
140+
docker.image('node:latest').inside{
141+
withEnv([
142+
/* Override the npm cache directory to avoid: EACCES: permission denied, mkdir '/.npm' */
143+
'npm_config_cache=npm-cache',
144+
/* set home to our current directory because other bower
145+
* nonsense breaks with HOME=/, e.g.:
146+
* EACCES: permission denied, mkdir '/.config'
147+
*/
148+
'HOME=.',
149+
]) {
150+
sh "npm uninstall asposewordscloud"
151+
sh "npm install asposewordscloud"
152+
}
153+
}
136154

137-
sh "git diff --name-status"
138-
sh 'git commit -am "reference changed to published package" || exit 0'
139-
sh "git push ${gitRepoUrl} testPackage"
155+
sh "git diff --name-status"
156+
sh 'git commit -am "reference changed to published package" || exit 0'
157+
sh "git push ${gitRepoUrl} testPackage"
158+
}
140159
}
141160

142-
stage('add version tag') {
143-
final fullVersion = packageName.substring(packageName.lastIndexOf('@') + 1, packageName.length())
144-
final version = fullVersion.substring(0, fullVersion.lastIndexOf('.'))
161+
gitlabCommitStatus("add version tag") {
162+
stage('add version tag') {
163+
final fullVersion = packageName.substring(packageName.lastIndexOf('@') + 1, packageName.length())
164+
final version = fullVersion.substring(0, fullVersion.lastIndexOf('.'))
145165

146-
sh "git tag -a ${version} -m \"version ${version}\""
147-
sh "git push ${gitRepoUrl} ${version}"
166+
sh "git tag -a ${version} -m \"version ${version}\""
167+
sh "git push ${gitRepoUrl} ${version}"
168+
}
148169
}
149-
150170
} finally {
151171
deleteDir()
172+
sh 'docker system prune -f'
152173
}
153174
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)