39 lines
1.1 KiB
Groovy
39 lines
1.1 KiB
Groovy
pipeline {
|
|
agent any
|
|
|
|
environment {
|
|
GIT_CREDENTIALS = '560c52f4-4213-4fb3-a757-620b6d3f119c' // This should be the ID of your Jenkins credentials
|
|
}
|
|
|
|
stages {
|
|
stage('Checkout') {
|
|
steps {
|
|
checkout([
|
|
$class: 'GitSCM',
|
|
branches: [[name: '*/main']],
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
} |