From 13d0cf14be4e5f5e43d240f79c951e6ff2a42147 Mon Sep 17 00:00:00 2001 From: TBS093A Date: Tue, 1 Mar 2022 13:28:35 +0100 Subject: [PATCH] modify Jenkinsfile --- Jenkinsfile | 52 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 59f9b26..15caa0e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,9 +1,9 @@ pipeline { agent any stages { - stage('#1 Build App') { + stage('#1 Fetch App') { steps { - echo '#1 Build App' + echo '#1 Fetch App' sh 'rm -r *' @@ -12,14 +12,50 @@ pipeline { sh 'ls -la' } } - stage('#2 Build App') { + stage('#2 Deploy to node (npm node)') { steps { - echo '#2 Build App' - - sh 'npm install' + echo '#2 Deploy to node (npm node)' - sh 'npm gatsby build' + sshPublisher( + publishers: [ + sshPublisherDesc( + configName: 'aws - kamil-zuk-cv.tk - 13.48.201.185', + transfers: [ + sshTransfer( + cleanRemote: false, + excludes: '', + execCommand: 'ls -la', + execTimeout: 120000, + flatten: false, + makeEmptyDirs: false, + noDefaultExcludes: false, + patternSeparator: '[, ]+', + remoteDirectory: './docker-compose/volumes/jenkins-npm-node/kamil-zuk-cv.tk', + remoteDirectorySDF: false, + removePrefix: '', + sourceFiles: './*' + ) + ], + usePromotionTimestamp: false, + useWorkspaceInPromotion: false, + verbose: false + ) + ] + ) + echo 'Deploy on node success' + } + } + stage('#3 Build App (npm node)') { + steps { + echo '#2 Build App (npm node)' + + withCredentials([sshUserPrivateKey(credentialsId: 'cv-kamil-zuk', keyFileVariable: 'keyfile')]) { + script { + sh 'scp -i ${keyfile} -r ./ ubuntu@13.48.201.185:/home/ubuntu/docker-compose/volumes/jenkins-npm-node/kamil-zuk-cv.tk ' + sh 'ssh -i ${keyfile} -t "cd /home/ubuntu/docker-compose/volumes/jenkins-npm-node/kamil-zuk-cv.tk ; npm install ; npm gatsby build"' + } + } } } stage('#3 Deploy App') { @@ -40,7 +76,7 @@ pipeline { makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', - remoteDirectory: '', + remoteDirectory: './docker-compose/volumes/https-nginx-static/kamil-zuk-cv.tk', remoteDirectorySDF: false, removePrefix: '', sourceFiles: './public/*'