Compare commits
3 Commits
cbc3cc26ed
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5124b13e59 | |||
| 9d3b41f338 | |||
| 5e4a63af9c |
8
.groovylintrc.json
Normal file
8
.groovylintrc.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "recommended",
|
||||||
|
"rules": {
|
||||||
|
"NestedBlockDepth": {
|
||||||
|
"enabled": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
71
Jenkinsfile
vendored
71
Jenkinsfile
vendored
@@ -1,35 +1,28 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
|
|
||||||
agent none
|
agent none
|
||||||
|
|
||||||
environment {
|
environment {
|
||||||
HOME = "${env.WORKSPACE}"
|
HOME = "${env.WORKSPACE}"
|
||||||
DOCKER_REGISTRY = 'https://registry.digitalocean.com'
|
PYTHON_IMAGE = 'python:3.10-slim-bullseye'
|
||||||
DOCKER_IMAGE_NAME = 'registry.digitalocean.com/ailuridae-registry/ailuridae.io/everybodymov'
|
CREDENTIALS_ID = 'digital-ocean-ailuridae-registry'
|
||||||
DOCKER_IMAGE = ''
|
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 {
|
stages {
|
||||||
stage('Setup') {
|
stage('Check') {
|
||||||
agent {
|
agent {
|
||||||
docker {
|
docker {
|
||||||
image 'python:3.10-slim-bullseye'
|
image env.PYTHON_IMAGE
|
||||||
|
args '--rm'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
sh 'python -m pip install --no-cache-dir --upgrade --user pip'
|
sh 'python -m pip install --no-cache-dir --upgrade --user pip'
|
||||||
sh 'python -m pip install --no-cache-dir pipenv --user'
|
sh 'python -m pip install --no-cache-dir --user pipenv'
|
||||||
sh 'python -m pipenv install --dev'
|
sh 'python -m pipenv install --dev --deploy'
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Check') {
|
|
||||||
agent {
|
|
||||||
docker {
|
|
||||||
image 'python:3.10-slim-bullseye'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
sh 'python -m pipenv verify'
|
|
||||||
sh 'python -m pipenv check --clear'
|
sh 'python -m pipenv check --clear'
|
||||||
sh 'python -m pipenv run bandit *.py'
|
sh 'python -m pipenv run bandit *.py'
|
||||||
}
|
}
|
||||||
@@ -40,7 +33,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
DOCKER_IMAGE = docker.build("${DOCKER_IMAGE_NAME}")
|
IMAGE_BUILD = docker.build("${IMAGE_NAME}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,11 +41,44 @@ pipeline {
|
|||||||
agent {
|
agent {
|
||||||
label 'main'
|
label 'main'
|
||||||
}
|
}
|
||||||
|
when {
|
||||||
|
branch 'main'
|
||||||
|
}
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
docker.withRegistry(env.DOCKER_REGISTRY, 'digital-ocean-ailuridae-registry') {
|
// withCredentials is annoyingly required to mask token occurrences.
|
||||||
DOCKER_IMAGE.push("${BUILD_NUMBER}")
|
withCredentials([usernamePassword(
|
||||||
DOCKER_IMAGE.push('latest')
|
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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user