Created
January 7, 2021 12:42
-
-
Save cloudyyoung/cec1f5849bdb25eb82063b4da3a09af2 to your computer and use it in GitHub Desktop.
Jenkinsfile - Build PHP by Composer and deploy to server by Publish Over SSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pipeline { | |
| agent any | |
| environment { | |
| DEPLOY_DIR = "/home/wwwroot/default/charity-jenkins" | |
| DEPLOY_NAME = "deploy.tar.gz" | |
| } | |
| stages { | |
| stage('Build') { | |
| steps { | |
| sh 'php --ini' | |
| sh 'composer install --no-dev' | |
| } | |
| } | |
| stage('Compress') { | |
| steps { | |
| sleep 4 | |
| sh "tar -cvz --warning=no-file-changed --exclude=\'.git\' --exclude=${DEPLOY_NAME} -f ${DEPLOY_NAME} ." | |
| } | |
| } | |
| stage('Deploy') { | |
| steps { | |
| sshPublisher( | |
| continueOnError: false, | |
| failOnError: true, | |
| publishers: [ | |
| sshPublisherDesc( | |
| configName: "Charity Server", | |
| verbose: true, | |
| transfers: [ | |
| sshTransfer( | |
| sourceFiles: "deploy.tar.gz", | |
| removePrefix: "", | |
| remoteDirectory: "${DEPLOY_DIR}", | |
| execCommand: """ | |
| cd ${DEPLOY_DIR} | |
| tar -xzvf deploy.tar.gz | |
| """, | |
| ) | |
| ] | |
| ) | |
| ] | |
| ) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment