-
Notifications
You must be signed in to change notification settings - Fork 0
/
original.jenkinsfile
30 lines (29 loc) · 1.36 KB
/
original.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
pipeline {
agent any
stages {
stage('Build and Test') {
steps {
echo 'building and testing...'
nodejs(cacheLocationStrategy: workspace(), nodeJSInstallationName: 'NodeJS') {
// Install pnpm globally, clean cache, and install dependencies
sh 'npm install -g pnpm'
sh 'npm cache clean --force'
sh 'pnpm install --store=node_modules/.pnpm-store'
sh 'pnpm run test'
}
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
withCredentials([usernamePassword(credentialsId: 'myDockerID', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
sh 'curl -fsSL https://get.docker.com -o get-docker.sh'
sh 'sudo sh get-docker.sh'
sh 'docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" https://index.docker.io/v1/'
sh 'docker build -t ${DOCKER_USERNAME}/${GITHUB_REPO_NAME}:v${BUILD_NUMBER} -f dockerfile .'
sh 'docker push ${DOCKER_USERNAME}/${GITHUB_REPO_NAME}:v${BUILD_NUMBER}'
}
}
}
}
}