edit-jenkinsfile #71
31
Jenkinsfile
vendored
31
Jenkinsfile
vendored
@@ -2,10 +2,35 @@ pipeline {
|
|||||||
agent any
|
agent any
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Do nothing') {
|
stage('Environment') {
|
||||||
steps {
|
steps {
|
||||||
sh '/bin/true'
|
sh 'git --version'
|
||||||
|
sh 'printenv'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Build Frontend') {
|
||||||
|
steps {
|
||||||
|
script{
|
||||||
|
def SCRIPT_OUTPUT1 = sh (script: 'sudo bash ./jenkins/buildFrontend.sh ${BRANCH_NAME}',returnStdout: true)
|
||||||
|
echo "Script Output: ${SCRIPT_OUTPUT1}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy Backend') {
|
||||||
|
steps {
|
||||||
|
script{
|
||||||
|
def SCRIPT_OUTPUT2 = sh (script: 'sudo bash ./jenkins/deployBackend.sh ${BRANCH_NAME}',returnStdout: true)
|
||||||
|
echo "Script Output: ${SCRIPT_OUTPUT2}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Deploy Frontend') {
|
||||||
|
steps {
|
||||||
|
script{
|
||||||
|
def SCRIPT_OUTPUT2 = sh (script: 'sudo bash ./jenkins/deployFrontend.sh ${BRANCH_NAME}',returnStdout: true)
|
||||||
|
echo "Script Output: ${SCRIPT_OUTPUT2}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|||||||
|
|||||||
13
jenkins/buildFrontend.sh
Normal file
13
jenkins/buildFrontend.sh
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
cd ./frontend
|
||||||
|
|
||||||
|
if test "$1" = "master"
|
||||||
|
then
|
||||||
|
echo 'Install neccessary Packages'
|
||||||
|
yarn install
|
||||||
|
echo 'Build Frontend for Production'
|
||||||
|
yarn run build
|
||||||
|
else
|
||||||
|
echo "Skipping for non-master branch"
|
||||||
|
fi
|
||||||
15
jenkins/deployBackend.sh
Normal file
15
jenkins/deployBackend.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
if test "$1" = "master"
|
||||||
|
then
|
||||||
|
echo 'Stop node process'
|
||||||
|
ssh -i /etc/ssh/simco_key simco-jenkins@gitea.oliver.boehlk.io "killall node"
|
||||||
|
echo 'Remove old backend folder'
|
||||||
|
ssh -i /etc/ssh/simco_key simco-jenkins@gitea.oliver.boehlk.io "rm -r ~/simco-dashboard/backend"
|
||||||
|
echo 'Copy backend to OlberryPi'
|
||||||
|
scp -i /etc/ssh/simco_key -r backend simco-jenkins@gitea.oliver.boehlk.io:~/simco-dashboard
|
||||||
|
echo 'Yarn install packages'
|
||||||
|
ssh -i /etc/ssh/simco_key simco-jenkins@gitea.oliver.boehlk.io "cd ~/simco-dashboard/backend && yarn install"
|
||||||
|
else
|
||||||
|
echo "Skipping for non-master branch"
|
||||||
|
fi
|
||||||
15
jenkins/deployFrontend.sh
Normal file
15
jenkins/deployFrontend.sh
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
if test "$1" = "master"
|
||||||
|
then
|
||||||
|
echo 'Remove old frontend folder'
|
||||||
|
ssh -i /etc/ssh/simco_key simco-jenkins@gitea.oliver.boehlk.io "rm -r ~/simco-dashboard/backend/frontend"
|
||||||
|
echo 'Copy frontend build to OlberryPi'
|
||||||
|
scp -i /etc/ssh/simco_key -r frontend/build simco-jenkins@gitea.oliver.boehlk.io:~/simco-dashboard/backend
|
||||||
|
echo 'Rename build folder to frontend'
|
||||||
|
ssh -i /etc/ssh/simco_key simco-jenkins@gitea.oliver.boehlk.io "mv ~/simco-dashboard/backend/build ~/simco-dashboard/backend/frontend"
|
||||||
|
echo "Start node server"
|
||||||
|
ssh -i /etc/ssh/simco_key simco-jenkins@gitea.oliver.boehlk.io "cd ~/simco-dashboard/backend && yarn run start" &
|
||||||
|
else
|
||||||
|
echo "Skipping for non-master branch"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user
important change