From 5124b13e5960d561ccb96ab1679ae103f37ab83b Mon Sep 17 00:00:00 2001 From: Amber Date: Sun, 4 Sep 2022 00:40:46 -0400 Subject: [PATCH] Force deploy --- Jenkinsfile | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2257f24..18c67f5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,22 +8,10 @@ pipeline { REGISTRY = 'https://registry.digitalocean.com' IMAGE_NAME = 'registry.digitalocean.com/ailuridae-registry/ailuridae.io/everybodymov' IMAGE_BUILD = '' + APP_ID = credentials('digital-ocean-app-id') } stages { - stage('Setup') { - agent { - docker { - image env.PYTHON_IMAGE - args '--rm' - } - } - steps { - sh 'python -m pip install --no-cache-dir --upgrade --user pip' - sh 'python -m pip install --no-cache-dir pipenv --user' - sh 'python -m pipenv install --dev' - } - } stage('Check') { agent { docker { @@ -32,7 +20,9 @@ pipeline { } } steps { - sh 'python -m pipenv verify' + sh 'python -m pip install --no-cache-dir --upgrade --user pip' + sh 'python -m pip install --no-cache-dir --user pipenv' + sh 'python -m pipenv install --dev --deploy' sh 'python -m pipenv check --clear' sh 'python -m pipenv run bandit *.py' } @@ -56,7 +46,7 @@ pipeline { } steps { script { - // withCredentials annoyingly required to mask token. + // withCredentials is annoyingly required to mask token occurrences. withCredentials([usernamePassword( credentialsId: env.CREDENTIALS_ID, usernameVariable: 'API_TOKEN_USER', @@ -70,6 +60,29 @@ pipeline { } } } + stage('Deploy') { + agent { + label 'main' + } + when { + branch 'main' + } + steps { + script { + withCredentials([usernamePassword( + credentialsId: env.CREDENTIALS_ID, + usernameVariable: 'API_TOKEN_USER', + passwordVariable: 'API_TOKEN_PASS' + )]) { + sh ''' + curl -H "Authorization: Bearer $API_TOKEN_PASS" -H "Content-Type: application/json" \ + -X POST "https://api.digitalocean.com/v2/apps/$APP_ID/deployments" \ + -d "{ \\"force_build\\" : true }" + ''' + } + } + } + } } post {