NAM-APJATEL-BACKEND/Jenkinsfile

39 lines
1.1 KiB
Groovy

pipeline {
agent any
environment {
GIT_CREDENTIALS = '8242519c-ed9e-447a-ad63-1f8d7368cf68' // This should be the ID of your Jenkins credentials
}
stages {
stage('Checkout') {
steps {
checkout([
$class: 'GitSCM',
branches: [[name: '*/dev']],
doGenerateSubmoduleConfigurations: false,
extensions: [],
userRemoteConfigs: [[
url: 'https://git.winteraccess.id/winter-access/backend_nam.git',
credentialsId: env.GIT_CREDENTIALS
]]
])
}
}
stage('Build and Deploy') {
steps {
sh 'go mod tidy'
sh 'go build -o myapp'
sh 'sudo cp myapp /home/developer/backend_nam/'
}
}
stage('Restart Service') {
steps {
sh 'sudo systemctl daemon-reload'
sh 'sudo systemctl restart backend-nam'
}
}
}
}