pipeline { agent any environment { BUILD_IMAGE = 'python:3.9-slim' AWS_REGION = 'us-east-1' AWS_ACCOUNT_ID = '123456789012' CODEART_DOMAIN = 'jacquesingram' CODEART_REPO = 'hello-codeartifact' CODEART_TOKEN = credentials('codeartifact-token') } stages { stage('Checkout') { steps { checkout scm } } stage('Setup') { steps { script { docker.image(env.BUILD_IMAGE).inside { sh ''' pip install --upgrade pip pip install build twine pytest if [ -f requirements.txt ]; then pip install -r requirements.txt fi ''' } } } } stage('Build') { steps { script { docker.image(env.BUILD_IMAGE).inside { sh ''' python -m build ''' } } } } stage('Test') { steps { script { docker.image(env.BUILD_IMAGE).inside { sh ''' python -m pytest tests/ --junitxml=test-results.xml || true ''' } } } post { always { // Publish test results if they exist script { if (fileExists('test-results.xml')) { publishTestResults testResultsPattern: 'test-results.xml' } } } } } stage('Publish') { steps { script { docker.image(env.BUILD_IMAGE).inside('-e HOME=/tmp') { sh ''' # Configure twine for CodeArtifact in /tmp cat > /tmp/.pypirc <