You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.2 KiB
Groovy

pipeline {
agent { label 'Linux' }
stages {
stage('Build Docker Image') {
environment {
version = "1.0.${env.BUILD_NUMBER}"
}
steps {
sh 'apt install -y git-lfs'
sh 'git lfs pull'
sh 'docker build --no-cache -t registry.miaostay.com/kotadoc -f Dockerfile .'
}
}
stage('Push to Registry') {
when {
anyOf {
branch 'master'
}
}
environment {
version = "1.0.${env.BUILD_NUMBER}"
}
steps {
sh 'docker push registry.miaostay.com/kotadoc'
}
}
stage('Deploy to Production Server') {
when {
anyOf {
branch 'master'
}
}
environment {
SERVER_CREDENTIALS = credentials('868e1509-ec55-4a4e-9296-042ca7e8b0eb')
SERVER_IP = credentials('3e762d69-418d-4283-95ac-913f19d7fe4e')
SERVER_PORT = credentials('736149c1-675d-470d-abce-3fb9e8e146c0')
}
steps {
sh 'apt update -y'
sh 'apt install -y sshpass'
sh 'sshpass -p $SERVER_CREDENTIALS_PSW ssh -p $SERVER_PORT $SERVER_CREDENTIALS_USR@$SERVER_IP "cd /data/kotadoc && kubectl delete pods kotadoc && kubectl apply -f kotadoc.yaml"'
}
}
}
}