Compare commits

..

3 Commits

Author SHA1 Message Date
5124b13e59 Force deploy
All checks were successful
Apps/everybody-mov/pipeline/head This commit looks good
2022-09-04 01:31:08 -04:00
9d3b41f338 Performing better masking on credentials; renaming env variables; cleaning up after Docker agents.
All checks were successful
Apps/everybody-mov/pipeline/head This commit looks good
2022-09-03 23:44:14 -04:00
5e4a63af9c Only publish on main
All checks were successful
Apps/everybody-mov/pipeline/head This commit looks good
2022-09-02 00:39:07 -04:00
2 changed files with 58 additions and 25 deletions

8
.groovylintrc.json Normal file
View File

@@ -0,0 +1,8 @@
{
"extends": "recommended",
"rules": {
"NestedBlockDepth": {
"enabled": false
}
}
}

71
Jenkinsfile vendored
View File

@@ -1,35 +1,28 @@
pipeline {
agent none
environment {
HOME = "${env.WORKSPACE}"
DOCKER_REGISTRY = 'https://registry.digitalocean.com'
DOCKER_IMAGE_NAME = 'registry.digitalocean.com/ailuridae-registry/ailuridae.io/everybodymov'
DOCKER_IMAGE = ''
PYTHON_IMAGE = 'python:3.10-slim-bullseye'
CREDENTIALS_ID = 'digital-ocean-ailuridae-registry'
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') {
stage('Check') {
agent {
docker {
image 'python:3.10-slim-bullseye'
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 {
image 'python:3.10-slim-bullseye'
}
}
steps {
sh 'python -m pipenv verify'
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'
}
@@ -40,7 +33,7 @@ pipeline {
}
steps {
script {
DOCKER_IMAGE = docker.build("${DOCKER_IMAGE_NAME}")
IMAGE_BUILD = docker.build("${IMAGE_NAME}")
}
}
}
@@ -48,11 +41,44 @@ pipeline {
agent {
label 'main'
}
when {
branch 'main'
}
steps {
script {
docker.withRegistry(env.DOCKER_REGISTRY, 'digital-ocean-ailuridae-registry') {
DOCKER_IMAGE.push("${BUILD_NUMBER}")
DOCKER_IMAGE.push('latest')
// withCredentials is annoyingly required to mask token occurrences.
withCredentials([usernamePassword(
credentialsId: env.CREDENTIALS_ID,
usernameVariable: 'API_TOKEN_USER',
passwordVariable: 'API_TOKEN_PASS'
)]) {
docker.withRegistry(env.REGISTRY, env.CREDENTIALS_ID) {
IMAGE_BUILD.push("${BUILD_NUMBER}")
IMAGE_BUILD.push('latest')
}
}
}
}
}
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 }"
'''
}
}
}
@@ -66,5 +92,4 @@ pipeline {
}
}
}
}