everybody-mov/Jenkinsfile

79 lines
2.2 KiB
Plaintext
Raw Normal View History

pipeline {
agent none
environment {
HOME = "${env.WORKSPACE}"
2022-09-04 03:28:54 +00:00
CREDENTIALS_ID = 'digital-ocean-ailuridae-registry'
DOCKER_REGISTRY = 'https://registry.digitalocean.com'
DOCKER_IMAGE_NAME = 'registry.digitalocean.com/ailuridae-registry/ailuridae.io/everybodymov'
DOCKER_IMAGE = ''
}
stages {
stage('Setup') {
agent {
docker {
image 'python:3.10-slim-bullseye'
}
}
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 pipenv check --clear'
sh 'python -m pipenv run bandit *.py'
}
}
stage('Build') {
agent {
label 'main'
}
steps {
script {
DOCKER_IMAGE = docker.build("${DOCKER_IMAGE_NAME}")
}
}
}
stage('Publish') {
agent {
label 'main'
}
2022-09-04 03:28:54 +00:00
// when {
// branch 'main'
// }
steps {
script {
2022-09-04 03:34:01 +00:00
withCredentials([usernamePassword(
2022-09-04 03:28:54 +00:00
credentialsId: env.CREDENTIALS_ID,
usernameVariable: 'JENKINS_USERNAME',
2022-09-04 03:34:01 +00:00
passwordVariable: 'JENKINS_PASSWORD'
)]) {
2022-09-04 03:28:54 +00:00
docker.withRegistry(env.DOCKER_REGISTRY, env.CREDENTIALS_ID) {
DOCKER_IMAGE.push("${BUILD_NUMBER}")
DOCKER_IMAGE.push('latest')
}
}
}
}
}
}
post {
always {
node('main') {
cleanWs()
}
}
}
2022-09-04 03:28:54 +00:00
}