-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJenkinsfile
45 lines (41 loc) · 1.44 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
pipeline {
agent { label 'agent'}
environment {
NPM_AUTH_TOKEN = credentials('Appcircle-CLI-NPM-Cred')
}
stages {
stage('Publish') {
steps {
sh '''#!/bin/bash
# shellcheck shell=bash
set -x
set -euo pipefail
tag=$(git describe --tags --abbrev=0)
echo "Tag: ${tag}"
npmPublishCommand=""
if [[ "${tag}" == *"beta"* ]]; then
echo "Beta Release"
npmPublishCommand="npm publish --tag beta"
elif [[ "${tag}" == *"alpha"* ]]; then
echo "Alpha Release"
npmPublishCommand="npm publish --tag alpha"
else
echo "Production Release"
npmPublishCommand="npm publish"
fi
## Build the image and make it ready for publishing.
docker image build -t ac-cli .
## Publish the application.
publishStatus=0
# shellcheck disable=SC2086
if ! docker run --rm --env NPM_AUTH_TOKEN=${NPM_AUTH_TOKEN} ac-cli ${npmPublishCommand}; then
echo "Publishing failed"
publishStatus=1
fi
docker image rm ac-cli
exit $publishStatus
'''
}
}
}
}