CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

testland/jenkinsfile-test-stages

Use whenever the task is to run tests in Jenkins: declarative Jenkinsfile test stages, parallel stages across agents, post always/failure actions, JUnit report publishing and lockable resources for shared test infrastructure.

Quality

87%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Passed

No findings from the security scan

Overview
Quality
Evals
Security
Files

environment-and-triggers.mdreferences/

Jenkins - environment, credentials, resource locks, and triggers

Deeper recipes split out of jenkinsfile-test-stages SKILL.md: serializing shared infrastructure, injecting environment plus masked credentials, and scheduling / multi-branch behavior.

Lockable resources

pipeline {
    agent any

    stages {
        stage('Integration') {
            steps {
                lock(resource: 'shared-test-database') {
                    sh 'npm run test:integration'
                }
            }
        }
    }
}

lock(...) uses the Lockable Resources Plugin to serialize access to shared resources (test DB, license-locked tool, etc.).

Environment + credentials

pipeline {
    agent any

    environment {
        CI = 'true'
        NODE_ENV = 'test'
    }

    stages {
        stage('Test') {
            steps {
                withCredentials([string(credentialsId: 'npm-auth-token', variable: 'NODE_AUTH_TOKEN')]) {
                    sh 'npm ci && npm test'
                }
            }
        }
    }
}

withCredentials([...]) masks secrets in build logs.

Multi-branch + scheduled

pipeline {
    agent any

    triggers {
        cron('0 4 * * *')   // daily at 4 AM
        pollSCM('*/15 * * * *')   // poll every 15 min (or use webhook)
    }

    options {
        timeout(time: 30, unit: 'MINUTES')
        timestamps()
        ansiColor('xterm')
        buildDiscarder(logRotator(numToKeepStr: '20'))
    }

    stages { /* ... */ }
}

Per-branch behavior via Multibranch Pipeline job type (separate config in Jenkins UI).

SKILL.md

tile.json