-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJenkinsfile
87 lines (87 loc) · 2.85 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
// To run this Jenkinsfile, you need to have the following plugins installed:
// - NodeJS
// - CloudBees AWS Credentials
// - Pipeline: AWS Steps
pipeline {
agent any
tools {nodejs "19.4"}
environment {
CI = 'true'
github_repository = "github.com/SPANDigital/presidium-js"
github_key = credentials('github-pat')
}
stages {
stage("Install") {
steps {
sh 'npm install'
}
}
stage("Build") {
steps {
sh 'npm run build'
}
}
stage("Tag") {
environment {
github_url = 'https://$github_key@${github_repository}'
}
stages {
stage("Tag develop") {
when {
branch 'develop'
}
steps {
script {
TAG=sh(returnStdout: true, script: 'docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.6.4-debian.9-x64-5.0 /repo -output json -showvariable MajorMinorPatch')
}
}
}
stage("Tag main") {
when {
branch 'main'
}
steps {
script {
TAG=sh(returnStdout: true, script: 'docker run --rm -v "$(pwd):/repo" gittools/gitversion:5.6.4-debian.9-x64-5.0 /repo -output json -showvariable FullSemVer')
// Delete all old rfv tags
sh 'git push -q $github_url -d origin $(git tag -l "*-rfs.*")'
}
}
}
stage("Push Tag") {
when {
expression { TAG != null }
}
steps {
script {
sh "git tag v$TAG"
sh "git push -q $github_url --tags"
}
}
}
}
}
stage("S3 Upload") {
when{
buildingTag()
}
steps {
script {
withAWS(credentials: 'aws-credentials', region: 'us-east-2') {
s3Upload(file:'dist', bucket:'span-presidium', path:"presidium-js/$TAG_NAME")
}
}
}
}
stage("Github Release") {
when{
buildingTag()
}
steps {
script {
sh "curl -v -d \"{\"tag_name\": \"$TAG_NAME\"}\" -H \"Authorization: token $github_key\" -X POST \"https://api.github.com/repos/presidium-js/releases\""
}
}
}
}
}