Integrating automation framework with Jenkins for continuous integration and continuous deployment (CI/CD)
Keshab Fouzdar
Full Stack QA Engineer | ISTQB? Certified | AWS Certified Cloud Practitioner | Experian PowerCurve Collection Developer | Banking Domain | Selenium, RestAssured, Playwright, Codecept.js, Cypress
Integrating your codeceptjs automation framework with Jenkins for continuous integration and continuous deployment (CI/CD) involves several steps. These include setting up Jenkins, configuring your project, creating a Jenkinsfile for your pipeline, and ensuring that Jenkins can run your tests and generate reports. Here's a step-by-step guide to achieve this:
1. Setting Up Jenkins
Install Jenkins:
Start Jenkins:
Install Required Plugins:
Pipeline
NodeJS
Allure Jenkins Plugin (for Allure reports)
2. Configuring Your Project
Create a New Jenkins Job:
Configure NodeJS:
3. Creating a Jenkinsfile
Create a Jenkinsfile in the root of your project directory. This file will define the stages and steps for your Jenkins pipeline. Here is an example Jenkinsfile:
领英推荐
pipeline {
agent any
environment {
NODEJS_HOME = tool name: 'NodeJS 14.x', type: 'NodeJSInstallation'
PATH = "${env.NODEJS_HOME}/bin:${env.PATH}"
}
stages {
stage('Install Dependencies') {
steps {
script {
// Clean and install dependencies
sh 'npm install'
}
}
}
stage('Run Tests') {
steps {
script {
// Run the tests
sh 'npx codeceptjs run'
}
}
}
stage('Generate Allure Report') {
steps {
script {
// Generate the Allure report
sh 'allure generate ./output/allure-results --clean'
}
}
}
stage('Publish Allure Report') {
steps {
allure([
includeProperties: false,
jdk: '',
properties: [],
reportBuildPolicy: 'ALWAYS',
results: [[path: 'output/allure-results']]
])
}
}
}
post {
always {
// Clean up workspace
cleanWs()
}
}
}
4. Configuring Jenkins Job
1. Pipeline Script from SCM:
2. Save and Build:
5. Running the Pipeline
1. Start a Build:
2. View Allure Report:
Additional Considerations
By following these steps, you can set up a Jenkins CI/CD pipeline for your automation framework, allowing you to run your tests and generate reports automatically with each code change.