-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJenkinsfile
45 lines (42 loc) · 1.56 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 any
parameters {
string(name: 'BRANCH_NAME', defaultValue: 'prod-main', description: 'Branch to build')
}
stages {
stage('Clone Repository') {
steps {
// Clean workspace before cloning
deleteDir()
// Clone repository with the parameterized branch
git branch: "${BRANCH_NAME}", url: 'https://github.com/NIUANULP/nulp-elite-ui.git'
}
}
stage('Build') {
environment {
// Define the Node.js version to use
NODE_VERSION = '18' // Adjust this to your desired Node.js version
NVM_DIR = '/var/lib/jenkins/.nvm'
}
steps {
// Install dependencies and build
sh '''
#!/bin/bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
if [ -s "$NVM_DIR/nvm.sh" ]; then
. "$NVM_DIR/nvm.sh"
fi
if [ -s "$NVM_DIR/bash_completion" ]; then
. "$NVM_DIR/bash_completion"
fi
nvm install $NODE_VERSION
nvm use $NODE_VERSION
yarn install
yarn build
cp -r /var/lib/jenkins/workspace/Build/Core/dist /var/lib/jenkins/workspace/Build/Core/elite-ui/prod/
'''
}
}
}
}