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
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Jenkinsfile
vendored
75
Jenkinsfile
vendored
@@ -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,12 +41,45 @@ 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 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user