diff --git a/Jenkinsfile b/Jenkinsfile index 240df97..ae9a198 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,37 +3,35 @@ node { checkout scm } + stage ("Dependencies") { + sh "npm ci" + } + + stage ("Build Gatsby") { + environment { + GATSBY_FIREBASE_API_KEY = credentials('FIREBASE_API_KEY') + GATSBY_AUTH_DOMAIN = "spencassemble-sol-journal.firebaseapp.com" + GATSBY_DATABASE_URL = "https://spencassemble-sol-journal.firebaseio.com" + GATSBY_PROJECT_ID = "spencassemble-sol-journal" + GATSBY_STORAGE_BUCKET = "spencassemble-sol-journal.appspot.com" + GATSBY_MESSAGING_SENDER_ID = "299522647169" + GATSBY_APP_ID = "1:299522647169:web:fc74af44747fd7cef79980" + } + steps { + sh "npm run build" + } + } + docker.withServer("ssh://rancher@192.168.1.116") { - docker.image("node:fermium-alpine").inside { - stage ("Dependencies") { - sh "npm ci" - } + stage ("Build Container") { + sh "docker image build -t spencerpincott/sol-journal:1.${env.BUILD_NUMBER} ." + } - stage ("Build Gatsby") { - environment { - GATSBY_FIREBASE_API_KEY = credentials('FIREBASE_API_KEY') - GATSBY_AUTH_DOMAIN = "spencassemble-sol-journal.firebaseapp.com" - GATSBY_DATABASE_URL = "https://spencassemble-sol-journal.firebaseio.com" - GATSBY_PROJECT_ID = "spencassemble-sol-journal" - GATSBY_STORAGE_BUCKET = "spencassemble-sol-journal.appspot.com" - GATSBY_MESSAGING_SENDER_ID = "299522647169" - GATSBY_APP_ID = "1:299522647169:web:fc74af44747fd7cef79980" - } - steps { - sh "npm run build" - } + stage ("Publish Container") { + withCredentials([usernamePassword(credentialsId: "DockerHub", usernameVariable: "DOCKERUSER", passwordVariable: "DOCKERPASS")]) { + sh 'docker login -u "$DOCKERUSER" -p "$DOCKERPASS"' } - - stage ("Build Container") { - sh "docker image build -t spencerpincott/sol-journal:1.${env.BUILD_NUMBER} ." - } - - stage ("Publish Container") { - withCredentials([usernamePassword(credentialsId: "DockerHub", usernameVariable: "DOCKERUSER", passwordVariable: "DOCKERPASS")]) { - sh 'docker login -u "$DOCKERUSER" -p "$DOCKERPASS"' - } - sh "docker image push spencerpincott/sol-journal:1.${env.BUILD_NUMBER}" - }d + sh "docker image push spencerpincott/sol-journal:1.${env.BUILD_NUMBER}" } }