mirror of
https://github.com/gutmensch/docker-dmarc-report.git
synced 2025-12-18 10:16:34 +00:00
update readme and pipeline
This commit is contained in:
parent
9637263016
commit
bf2f61f236
@ -2,7 +2,7 @@ ARG UPSTREAM_IMAGE=trafex/alpine-nginx-php7:2.0.2
|
||||
|
||||
FROM $UPSTREAM_IMAGE
|
||||
|
||||
LABEL maintainer="Robert Schumann <gutmensch@n-os.org>"
|
||||
LABEL maintainer="Robert Schumann <rs@n-os.org>"
|
||||
|
||||
ENV REPORT_PARSER_SOURCE="https://github.com/techsneeze/dmarcts-report-parser/archive/master.zip" \
|
||||
REPORT_VIEWER_SOURCE="https://github.com/techsneeze/dmarcts-report-viewer/archive/master.zip"
|
||||
|
||||
102
Jenkinsfile
vendored
102
Jenkinsfile
vendored
@ -1,18 +1,23 @@
|
||||
DOCKER_IMAGE = ''
|
||||
DOCKER_ARGS = '--network=services_default'
|
||||
DOCKER_REGISTRY = 'registry.n-os.org:5000'
|
||||
DOCKER_REPO = "${JOB_BASE_NAME}"
|
||||
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
|
||||
DOCKER_IMAGE_NAME = ''
|
||||
DOCKER_IMAGE = ''
|
||||
DOCKER_ARGS = '--network=services_default'
|
||||
DOCKER_REGISTRY = 'registry.n-os.org:5000'
|
||||
|
||||
|
||||
properties([
|
||||
parameters([
|
||||
string(defaultValue: 'trafex/alpine-nginx-php7:2.0.2', name: 'UPSTREAM_IMAGE', description: "Upstream docker image to start with")
|
||||
booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: 'Do you want to run the build with tests?')
|
||||
])
|
||||
])
|
||||
|
||||
|
||||
node {
|
||||
try {
|
||||
pipeline()
|
||||
setBuildStatus('Success', 'SUCCESS')
|
||||
}
|
||||
catch(e) {
|
||||
setBuildStatus(e.toString().take(140), 'FAILURE')
|
||||
@ -24,37 +29,86 @@ node {
|
||||
}
|
||||
|
||||
|
||||
// --- helper functions ---
|
||||
/*
|
||||
******************************************************************
|
||||
|
||||
standard functions
|
||||
these functions below implement the standard docker image pipeline
|
||||
|
||||
******************************************************************
|
||||
*/
|
||||
def pipeline() {
|
||||
stage('checkout') {
|
||||
|
||||
stage('checkout git') {
|
||||
checkout scm
|
||||
setBuildStatus('In progress...', 'PENDING')
|
||||
}
|
||||
|
||||
stage('image build') {
|
||||
DOCKER_IMAGE = docker.build(
|
||||
"${DOCKER_REGISTRY}/${DOCKER_REPO}:${BUILD_ID} ",
|
||||
"--build-arg UPSTREAM_IMAGE=${UPSTREAM_IMAGE} " +
|
||||
"--no-cache ${DOCKER_ARGS} ."
|
||||
)
|
||||
// https://docs.cloudbees.com/docs/admin-resources/latest/plugins/docker-workflow
|
||||
stage('build image') {
|
||||
DOCKER_IMAGE_NAME = "${DOCKER_REGISTRY}/${getDockerImage()}:${getDockerTag()}"
|
||||
DOCKER_IMAGE = docker.build(DOCKER_IMAGE_NAME, "--no-cache ${DOCKER_ARGS} .")
|
||||
}
|
||||
|
||||
// stage('run tests') {
|
||||
// DOCKER_IMAGE.inside("${DOCKER_ARGS} --entrypoint=") {
|
||||
// sh 'bats /usr/build/test/*.bats'
|
||||
// }
|
||||
// }
|
||||
stage('run tests') {
|
||||
if (fileExists('./test/run.sh') && !params.SKIP_TESTS) {
|
||||
DOCKER_IMAGE.inside("${DOCKER_ARGS} --entrypoint=") {
|
||||
sh 'bash /usr/build/test/run.sh'
|
||||
}
|
||||
}
|
||||
else {
|
||||
Utils.markStageSkippedForConditional('run tests')
|
||||
}
|
||||
}
|
||||
|
||||
stage('push image') {
|
||||
def shortHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||
DOCKER_IMAGE.push()
|
||||
DOCKER_IMAGE.push(shortHash)
|
||||
if (BRANCH_NAME == 'master') {
|
||||
DOCKER_IMAGE.push()
|
||||
}
|
||||
else {
|
||||
Utils.markStageSkippedForConditional('push image')
|
||||
}
|
||||
}
|
||||
|
||||
stage('delete image') {
|
||||
if (BRANCH_NAME == 'master') {
|
||||
Utils.markStageSkippedForConditional('delete image')
|
||||
}
|
||||
else {
|
||||
deleteDockerImage(DOCKER_IMAGE_NAME)
|
||||
}
|
||||
setBuildStatus('Success', 'SUCCESS')
|
||||
}
|
||||
}
|
||||
|
||||
def cleanup() {
|
||||
void deleteDockerImage(image) {
|
||||
sh(script: "docker rmi -f ${image}")
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
stage('schedule cleanup') {
|
||||
build job: '../Maintenance/dangling-container-cleanup', wait: false
|
||||
build job: '/maintenance/starter', wait: false
|
||||
}
|
||||
}
|
||||
|
||||
String getDockerImage() {
|
||||
return sh(script: "echo '${JOB_NAME}' | awk -F/ '{print \$(NF-1)}' | sed 's%docker-%%'", returnStdout: true).trim()
|
||||
}
|
||||
|
||||
String getDockerTag() {
|
||||
def shortHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||
def date = new Date()
|
||||
def sdf = new SimpleDateFormat("yyyyMMddHHmmss")
|
||||
// semver in TAG_ID file or reference to ARG in Dockerfile
|
||||
if (!fileExists('./TAG_ID')) {
|
||||
return "${sdf.format(date)}.${shortHash}.b${BUILD_ID}"
|
||||
}
|
||||
def tagId = sh(script: 'cat ./TAG_ID', returnStdout: true).trim()
|
||||
if (tagId ==~ /^[A-Z_]+$/) {
|
||||
return sh(script: "awk -F= '/ARG ${tagId}=/{print \$2}' Dockerfile", returnStdout: true).trim()
|
||||
}
|
||||
else {
|
||||
return tagId
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# docker-dmarc-report [](https://jenkins.bln.space/job/docker-images/job/docker-dmarc-report/) [](https://registry.hub.docker.com/u/gutmensch/dmarc-report/)
|
||||
# docker-dmarc-report [](https://jenkins.bln.space/job/docker-images/job/docker-jenkins/job/master/) [](https://registry.hub.docker.com/u/gutmensch/dmarc-report/)
|
||||
|
||||
This image is intended to combine a dmarc report parser (see https://github.com/techsneeze/dmarcts-report-parser by TechSneeze.com and John Bieling) with a report viewer (see https://github.com/techsneeze/dmarcts-report-viewer/ by the same people) into a runnable docker image / microservice.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user