Compare commits

..

5 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
cbc3cc26ed Merge branch 'main' of https://ailuridae.io/git/amber/everybody-mov
All checks were successful
Apps/everybody-mov/pipeline/head This commit looks good
Merging main
2022-09-02 00:37:06 -04:00
a066142307 Adding Jenkinsfile for checking, building, and publishing 2022-09-02 00:35:32 -04:00
4 changed files with 106 additions and 3 deletions

8
.groovylintrc.json Normal file
View File

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

View File

@@ -1,9 +1,9 @@
FROM python:3.10-alpine
WORKDIR /app
WORKDIR /app/
ENV PYTHONIOENCODING=utf-8
COPY Pipfile Pipfile.lock everybody.txt tweetbot.py /app
COPY Pipfile Pipfile.lock everybody.txt tweetbot.py /app/
# Install pipenv and compilation dependencies
RUN pip install pipenv && pipenv install --deploy --ignore-pipfile

95
Jenkinsfile vendored Normal file
View File

@@ -0,0 +1,95 @@
pipeline {
agent none
environment {
HOME = "${env.WORKSPACE}"
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('Check') {
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 --user pipenv'
sh 'python -m pipenv install --dev --deploy'
sh 'python -m pipenv check --clear'
sh 'python -m pipenv run bandit *.py'
}
}
stage('Build') {
agent {
label 'main'
}
steps {
script {
IMAGE_BUILD = docker.build("${IMAGE_NAME}")
}
}
}
stage('Publish') {
agent {
label 'main'
}
when {
branch 'main'
}
steps {
script {
// 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 }"
'''
}
}
}
}
}
post {
always {
node('main') {
cleanWs()
}
}
}
}

2
Pipfile.lock generated
View File

@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
"sha256": "3dc4c0a387fc9c5280d0dbfadae8f3d7cac3ddf589af5ec78dfe7090ff2684f2"
"sha256": "e7a1785570cb6182573b0e15cae2ad2c86adb2c280e88ceaa9126c232b720c9c"
},
"pipfile-spec": 6,
"requires": {