Using scipted ci
This commit is contained in:
parent
dc84580615
commit
8bfb22db0f
42
Jenkinsfile
vendored
42
Jenkinsfile
vendored
@ -1,64 +1,46 @@
|
||||
pipeline {
|
||||
agent any
|
||||
node {
|
||||
env.NODE_ENV = 'production'
|
||||
|
||||
environment {
|
||||
NODE_ENV = 'production'
|
||||
}
|
||||
|
||||
stages {
|
||||
try {
|
||||
stage('Setup Node.js') {
|
||||
steps {
|
||||
nodejs(nodeJSInstallationName: 'Node23') {
|
||||
sh 'node -v'
|
||||
sh 'npm -v'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Install Dependencies') {
|
||||
steps {
|
||||
nodejs(nodeJSInstallationName: 'Node23') {
|
||||
sh 'npm ci --include=dev'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
nodejs(nodeJSInstallationName: 'Node23') {
|
||||
sh 'npm run build'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy to printer1') {
|
||||
steps {
|
||||
script {
|
||||
def remote = [:]
|
||||
remote.name = 'printer1'
|
||||
remote.host = 'printer1.tombutcher.local'
|
||||
remote.user = 'ci'
|
||||
remote.password = 'ci'
|
||||
romote.password = 'ci'
|
||||
remote.allowAnyHosts = true
|
||||
// Upload the build folder
|
||||
|
||||
// Copy the build directory to the remote server
|
||||
sshPut remote: remote, from: 'build/', into: '/srv/farmcontrol-server/'
|
||||
|
||||
// Restart the service
|
||||
// Restart the service using sudo
|
||||
sshCommand remote: remote, command: 'sudo /bin/systemctl restart farmcontrol-server.service'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
echo 'Pipeline completed successfully!'
|
||||
} catch (Exception e) {
|
||||
echo 'Pipeline failed!'
|
||||
throw e
|
||||
} finally {
|
||||
cleanWs()
|
||||
}
|
||||
success {
|
||||
echo 'Pipeline completed successfully!'
|
||||
}
|
||||
failure {
|
||||
echo 'Pipeline failed!'
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user