pipeline {
agent {
kubernetes {
yaml """
apiVersion: v1
kind: Pod
spec:
containers:
- name: node-2290-build
image: python:3.9-slim-buster
command:
- cat
tty: true
securityContext:
privileged: true
runAsUser: 0
- name: jnlp
image: jenkins/inbound-agent:latest
args: ['\$(JENKINS_SECRET)', '\$(JENKINS_NAME)']
securityContext:
privileged: true
runAsUser: 0
- name: podman
image: quay.io/podman/stable
command:
- cat
tty: true
securityContext:
privileged: true
runAsUser: 0
- name: kubectl
image: dtzar/helm-kubectl
command:
- cat
tty: true
securityContext:
privileged: true
runAsUser: 0
"""
}
}
parameters {
string(name: 'CHASE_USER', defaultValue: '', description: 'Chase username')
string(name: 'CHASE_PASS', defaultValue: '', description: 'Chase password')
}
environment {
VENV_DIR = 'venv'
OUTPUTDIR = 'results'
CHASE_USER= "${params.CHASE_USER}"
CHASE_PASS= "${params.CHASE_PASS}"
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Setup Python') {
steps {
sh 'python3 -m venv $VENV_DIR'
sh '. $VENV_DIR/bin/activate && python -m pip install --upgrade pip'
// try installing from requirements.txt if present
sh '. $VENV_DIR/bin/activate && if [ -f requirements.txt ]; then pip install -r requirements.txt || true; fi'
// ensure Robot and common libs are installed
sh '. $VENV_DIR/bin/activate && pip install robotframework selenium robotframework-seleniumlibrary webdriver-manager || true'
}
}
stage('Create PVC') {
steps {
// Apply PVC manifest if kubectl is available
sh "if command -v kubectl >/dev/null 2>&1; then kubectl apply -f k8s/pvc-chrome-profile.yaml || true; kubectl wait --for=condition=bound pvc/chrome-profile-pvc --timeout=60s || true; else echo 'kubectl not found, skipping PVC creation'; fi"
}
}
stage('Run Robot Tests') {
steps {
sh '. $VENV_DIR/bin/activate && mkdir -p ${OUTPUTDIR} && ./jenkins/run_robot.sh'
}
post {
always {
archiveArtifacts artifacts: 'results/**', fingerprint: true
}
}
}
}
post {
failure {
echo 'Robot tests failed. See archived artifacts in results/ for details.'
}
}
}