Created
June 2, 2021 02:29
-
-
Save h3ct0rjs/e98e87f6ceb194a1a12ef8b9c4b817b0 to your computer and use it in GitHub Desktop.
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 | |
stages { | |
stage('Build') { | |
steps { | |
echo 'Running build automation' | |
sh './gradlew build' | |
archiveArtifacts artifacts: 'src/index.html' | |
} | |
} | |
stage('DeployToStage') { | |
when { | |
branch 'master' | |
} | |
steps { | |
withCredentials([string(credentialsId: 'cloud_user_pw', variable: 'USERPASS')]) { | |
sshPublisher( | |
failOnError: true, | |
publishers: [ | |
sshPublisherDesc( | |
configName: 'staging', | |
sshCredentials: [ | |
username: 'cloud_user', | |
encryptedPassphrase: "$USERPASS" | |
], | |
transfers: [ | |
sshTransfer( | |
sourceFiles: 'src/**', | |
removePrefix: 'src/' | |
) | |
] | |
) | |
] | |
) | |
} | |
} | |
} | |
stage('DeployToProd') { | |
when { | |
branch 'master' | |
} | |
steps { | |
input 'Does the staging environment look OK?' | |
milestone(1) | |
withCredentials([string(credentialsId: 'cloud_user_pw', variable: 'USERPASS')]) { | |
sshPublisher( | |
failOnError: true, | |
publishers: [ | |
sshPublisherDesc( | |
configName: 'production', | |
sshCredentials: [ | |
username: 'cloud_user', | |
encryptedPassphrase: "$USERPASS" | |
], | |
transfers: [ | |
sshTransfer( | |
sourceFiles: 'src/**', | |
removePrefix: 'src/' | |
) | |
] | |
) | |
] | |
) | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment