Skip to content

Commit

Permalink
Add Jenkins CI job for Postject
Browse files Browse the repository at this point in the history
Fixes: nodejs/postject#62
Signed-off-by: Darshan Sen <[email protected]>
  • Loading branch information
RaisinTen committed Dec 14, 2022
1 parent c35bdd2 commit 83f7ca5
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions jenkins/pipelines/postject.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env groovy

pipeline {
agent { label 'postject' }
parameters{
string(name: 'GITHUB_ORG', defaultValue: 'nodejs', description: 'The user/org of the GitHub repo')
string(name: 'REPO_NAME', defaultValue: 'postject', description: 'The name of the repo')
string(name: 'GIT_REMOTE_REF', defaultValue: 'refs/heads/main', description: 'The remote portion of the Git refspec to fetch and test')
}

stages {
stage("Setup repository") {
steps {
checkout(changelog: false, poll: false, scm: [
$class: 'GitSCM',
branches: [[
name: 'refs/heads/_jenkins_local_branch'
]],
userRemoteConfigs: [[
credentialsId: "96d5f81c-e9ad-45f7-ba5d-bc8107c0ae2c",
url: "[email protected]:${params.GITHUB_ORG}/${params.REPO_NAME}",
]]
])
}
}

stage('Pre-flight') {
steps {
// Make sure we have these binaries in the path
sh 'node --version'
sh 'npm --version'
sh 'git --version'
sh 'cmake --version'
sh 'ninja --version'
}
}


stage('Build postject') {
steps {
// Calling with `returnStatus` suppresses automatic failures
sh(script: "npm install", returnStatus: true)
sh(script: "git clone https://github.com/emscripten-core/emsdk.git", returnStatus: true)
sh(script: "(cd emsdk && ./emsdk install latest)", returnStatus: true)
sh(script: "(cd emsdk && ./emsdk activate latest)", returnStatus: true)
sh(script: "(cd emsdk && source ./emsdk_env.sh && cd .. && npm run build -- --jobs=3)", returnStatus: true)
}
}

stage('Lint') {
steps {
sh(script: "npm run lint", returnStatus: true)
}
}

stage('Run tests') {
steps {
sh(script: "npm test -- --reporter mocha-junit-reporter", returnStatus: true)
}
}
}

post {
success {
sendBuildStatus("success", env)
}

failure {
sendBuildStatus("failure", env)
}
}
}

def sendBuildStatus(status, env) {
build job: 'post-build-status-update', parameters: [
string(name: 'REPO', value: 'postject'),
string(name: 'IDENTIFIER', value: 'linter'),
string(name: 'URL', value: env.BUILD_URL),
string(name: 'COMMIT', value: sh(script: 'git rev-parse HEAD', returnStdout: true).trim()),
string(name: 'REF', value: env.GIT_REMOTE_REF),
string(name: 'STATUS', value: status)
]
}

0 comments on commit 83f7ca5

Please sign in to comment.