Skip to content

Commit 3fd1cf8

Browse files
Merge pull request #14 from superstreamlabs/add-pipeline
Add pipeline
2 parents d9955aa + ca4085c commit 3fd1cf8

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

Jenkinsfile

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@Library('shared-library') _
2+
3+
pipeline {
4+
5+
agent {
6+
label 'small-ec2-fleet'
7+
}
8+
9+
environment {
10+
HOME = '/tmp'
11+
SLACK_CHANNEL = '#jenkins-events'
12+
}
13+
14+
stages {
15+
stage('Extract Version') {
16+
steps {
17+
script {
18+
def pkgVersion = sh(script: "jq -r .version package.json", returnStdout: true).trim()
19+
env.versionTag = "v${pkgVersion}"
20+
}
21+
}
22+
}
23+
24+
stage('Install dependencies') {
25+
steps {
26+
sh 'npm install'
27+
sh 'npm pack'
28+
}
29+
}
30+
31+
stage('Publish') {
32+
steps {
33+
withCredentials([string(credentialsId: 'npm-token', variable: 'NPM_TOKEN')]) {
34+
sh '''
35+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
36+
npm publish
37+
'''
38+
}
39+
}
40+
}
41+
42+
stage('Create Release'){
43+
steps {
44+
sh """
45+
curl -L https://github.com/cli/cli/releases/download/v2.40.0/gh_2.40.0_linux_amd64.tar.gz -o gh.tar.gz
46+
tar -xvf gh.tar.gz
47+
sudo mv gh_2.40.0_linux_amd64/bin/gh /usr/local/bin
48+
rm -rf gh_2.40.0_linux_amd64 gh.tar.gz
49+
"""
50+
withCredentials([sshUserPrivateKey(keyFileVariable:'check',credentialsId: 'main-github')]) {
51+
sh """
52+
GIT_SSH_COMMAND='ssh -i $check -o StrictHostKeyChecking=no' git config --global user.email "[email protected]"
53+
GIT_SSH_COMMAND='ssh -i $check -o StrictHostKeyChecking=no' git config --global user.name "Jenkins"
54+
GIT_SSH_COMMAND='ssh -i $check -o StrictHostKeyChecking=no' git tag -a $versionTag -m "$versionTag"
55+
GIT_SSH_COMMAND='ssh -i $check -o StrictHostKeyChecking=no' git push origin $versionTag
56+
"""
57+
}
58+
withCredentials([string(credentialsId: 'gh_token', variable: 'GH_TOKEN')]) {
59+
sh """
60+
gh release upload $versionTag superstream-kafka-analyzer-${env.versionTag}.tgz --generate-notes
61+
"""
62+
}
63+
}
64+
}
65+
}
66+
post {
67+
always {
68+
cleanWs()
69+
}
70+
success {
71+
script {
72+
sendSlackNotification('SUCCESS')
73+
}
74+
}
75+
76+
failure {
77+
script {
78+
sendSlackNotification('FAILURE')
79+
}
80+
}
81+
aborted {
82+
script {
83+
sendSlackNotification('ABORTED')
84+
// Get the build log to check for the specific exception and retry job
85+
AgentOfflineException()
86+
}
87+
}
88+
}
89+
}

0 commit comments

Comments
 (0)