-
Notifications
You must be signed in to change notification settings - Fork 6
/
Jenkinsfile
85 lines (78 loc) · 3.07 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
pipeline {
agent any
environment {
// Define global variables here if needed
GIT_COMMIT_ID = ''
}
stages {
stage('Checkout') {
steps {
script {
deleteDir()
checkout scm
env.GIT_COMMIT_ID = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
currentBuild.displayName = "#${env.BUILD_NUMBER}:${env.VERSION}"
}
}
}
stage('Install Dependencies') {
steps {
script {
sh '''
# Check if NVM is already installed
if [ ! -d "$HOME/.nvm" ]; then
echo "Installing NVM"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm use system
npm uninstall -g a_module
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install
echo "Now using node version: $(node -v)"
echo "Now using npm version: $(npm -v)"
else
echo "NVM version $(node -v) is already installed"
fi
'''
}
}
}
stage('Generate and publish OpenAPI specs') {
when {
expression { return env.BRANCH_NAME == 'master' }
}
options {
timeout(time: 10, unit: 'MINUTES')
}
steps {
withCredentials([usernamePassword(credentialsId: 'delivery-instana-io-internal-project-artifact-read-writer-creds',
usernameVariable: 'DELIVERY_INSTANA_USR',
passwordVariable: 'DELIVERY_INSTANA_PWD'),
sshUserPrivateKey(credentialsId: 'id_openapi_public_github', keyFileVariable: 'SSH_KEY')]) {
sh '''
chmod 600 $SSH_KEY
'''
sh "GIT_SSH_COMMAND=\"ssh -i ${env.SSH_KEY} -o IdentitiesOnly=yes\" ./ci/publish.bash ${env.VERSION} ${env.BUILD_URL}"
}
}
}
stage('Trigger API end-to-end tests') {
when {
expression { return env.BRANCH_NAME == 'master' }
}
options {
timeout(time: 30, unit: 'MINUTES')
}
steps {
script {
def versionParts = env.VERSION.tokenize('.')
def releaseNumber = versionParts[1]
build job: '/tests/rest-api-e2e-tests', parameters: [
string(name: 'BRANCH_NAME', value: "release-${releaseNumber}"),
string(name: 'ENVIRONMENT', value: 'preview-instana')
]
}
}
}
}
}