Skip to content

Instantly share code, notes, and snippets.

@h3ct0rjs
Created June 2, 2021 02:29
Show Gist options
  • Save h3ct0rjs/e98e87f6ceb194a1a12ef8b9c4b817b0 to your computer and use it in GitHub Desktop.
Save h3ct0rjs/e98e87f6ceb194a1a12ef8b9c4b817b0 to your computer and use it in GitHub Desktop.
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