pipeline {
agent any
options {
timeout(time: 10, unit: 'MINUTES')
buildDiscarder(logRotator(numToKeepStr:'4'))
}
environment {
def DOCKER_DRIVER = "overlay2"
def DOCKER_BUILDKIT=1
def DOCKER_REG = credentials('cec23a25-eb2e-4331-bb78-940508d74d39')
}
stages {
stage ('Build CSS & JS') {
agent {
docker {
reuseNode true
}
}
steps {
sh "./build.sh css"
}
}
stage ('Download Database') {
agent {
docker {
reuseNode true
}
}
when {
not {
branch 'staging'
}
}
steps {
withCredentials([
file(credentialsId: 'aak.env.dev', variable: 'CRAFT_ENV_DEV'), file(credentialsId: 'aak.env.stage', variable: 'CRAFT_ENV_STAGE'),
file(credentialsId: 'aak.env.prod', variable: 'CRAFT_ENV_PROD')
]) {
sh "./build.sh dumpdb"
}
}
}
stage ('Prep image') {
agent {
docker {
reuseNode true
}
}
steps {
withCredentials([
sshUserPrivateKey(credentialsId: 'b59c3587-239d-4ed7-9252-a8f6a4eadfb7',
keyFileVariable: 'SSH_KEY', passphraseVariable: 'SSH_PASS', usernameVariable: 'SSH_USER'),
file(credentialsId: 'aak.env.dev', variable: 'CRAFT_ENV_DEV'), file(credentialsId: 'aak.env.stage', variable: 'CRAFT_ENV_STAGE'),
file(credentialsId: 'aak.env.prod', variable: 'CRAFT_ENV_PROD')
]) {
sh "./build.sh image"
}
}
}
stage ('Launch image') {
agent {
docker {
reuseNode true
}
}
steps {
sshagent(['b59c3587-239d-4ed7-9252-a8f6a4eadfb7']) {
script {
withCredentials([
file(credentialsId: 'aak.env.dev', variable: 'CRAFT_ENV_DEV'), file(credentialsId: 'aak.env.stage', variable: 'CRAFT_ENV_STAGE'),
file(credentialsId: 'aak.env.prod', variable: 'CRAFT_ENV_PROD')
]) {
sh "./build.sh launch"
}
}
}
}
}
}
}