Skip to content

Commit

Permalink
test?
Browse files Browse the repository at this point in the history
  • Loading branch information
LordLumineer committed May 9, 2024
1 parent 1baaefc commit 5572335
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
pipeline {
agent {
docker {
image 'node:14' // Use a Node.js Docker image as the build environment
args '-v $HOME/.npm:/root/.npm' // Mount the npm cache to speed up builds
}
}

stages {
stage('Checkout') {
steps {
// Checkout code from your repository
git credentialsId: 'github-credentials', url: 'https://github.com/your/repo.git'
}
}

stage('Build') {
steps {
// Run build commands here (e.g., npm install, mvn clean install)
sh 'npm install' // Example for Node.js project, adjust for your project's build system
}
}

stage('Test') {
steps {
// Run tests here
sh 'npm test' // Example for running tests with npm, adjust for your testing framework
}
}
}

post {
always {
// Post-build actions
// Report build status to GitHub
script {
// Set up GitHub Checks API parameters
def githubCreds = credentials('github-credentials') // Jenkins secret text credential containing GitHub personal access token
def apiUrl = 'https://api.github.com'
def gitHubContext = 'Jenkins CI' // Context for the GitHub status check
def gitHubUrl = env.BUILD_URL // URL to Jenkins build details
def gitHubCommit = sh(script: 'git rev-parse HEAD', returnStdout: true).trim()

// Report status to GitHub
withGitHubChecks(
credentialsId: githubCreds,
apiUrl: apiUrl,
commitSha: gitHubCommit,
context: gitHubContext,
url: gitHubUrl,
status: currentBuild.result == 'SUCCESS' ? 'success' : 'failure',
description: currentBuild.result == 'SUCCESS' ? 'Tests passed' : 'Tests failed'
)
}
}
}
}

0 comments on commit 5572335

Please sign in to comment.