Basic example with preparation and build stage

This example is very simple bootsrap that can be used for basic setup

Dockerfile

FROM python:3.8

RUN pip install awscli

Jenkinsfile

#!/env/bin/env groovy

def builder = null
def product = null

@Library("m2aJenkins") _

pipeline {
    agent any

    environment {
        VERSION = artifacts.get_version()
    }

    stages {
        stage("Prepare") {
            steps {
                script {
                    builder = docker.image("alpine")
                    product = docker.build("m2a-awesome-product:${VERSION}")
                }
            }
        }
        stage("Build & Test") {
            steps {
                script {
                    utils.build_notify(currentBuild, 'dummy-build', "Dummy build without any tests"){
                        builder.inside {
                            sh 'mkdir -p my-build'
                            sh 'echo built > my-build/my_artifact_0.0.0.raw'
                            product.inside {
                                sh "run test"
                            }
                        }
                    }
                }
            }
        }
    }

    post {
        success {
            script {
                utils.build_notify(currentBuild, 'artifact', "Deliver artifact"){
                    builder.inside {
                        def artName = artifacts.create_artifact('my-build')
                        artifacts.publish_image(product)
                        currentBuild.displayName += " [${artName}]"
                        return "Artifact ${artName} has been created"
                    }
                }
            }
        }

        cleanup {
            cleanWs()
        }
    }
}