Browse Source

Update 'Jenkinsfile'

main
william 5 days ago
parent
commit
28c1ab2849
  1. 36
      Jenkinsfile

36
Jenkinsfile

@ -1,14 +1,21 @@
pipeline {
agent any
stages {
stage('Checkout') {
stage("Checkout and build react app") {
when { expression { true } }
steps {
git 'http://git.abilityell.com/william/react-project.git'
}
}
stage('Build') {
steps {
sh 'mvn clean package'
git(url: 'http://git.abilityell.com/william/react-project.git', branch: 'main')
withEnv(['CI=false']) { //ignore warning
sh 'npm install'
sh 'npm run build'
}
sh '''
echo "build react ..."
pwd
ls -l build
'''
}
}
stage('Test') {
@ -16,11 +23,18 @@ pipeline {
sh 'mvn test'
}
}
stage('Deploy') {
stage("Deploy React App") {
when { expression { false } }
steps {
sh 'kubectl apply -f deployment.yaml'
withCredentials([sshUserPrivateKey(credentialsId: 'docker-ssh', keyFileVariable: 'SSH_KEY')]) {
sh '''
scp -i $SSH_KEY -o StrictHostKeyChecking=no -r build/* $DOCKER_HOST:/var/www/html/
ssh -i $SSH_KEY -o StrictHostKeyChecking=no $DOCKER_HOST 'chmod -R 755 /var/www/html/*'
'''
}
}
}
}
}
post {
success {
@ -30,4 +44,4 @@ pipeline {
echo "Pipeline failed! ❌"
}
}
}
}
Loading…
Cancel
Save