Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions jenkins/http-parser.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env groovy

import groovy.json.JsonOutput

pipeline {
agent { label 'jenkins-workspace' }

parameters {
booleanParam(name: 'CERTIFY_SAFE', defaultValue: false, description: 'I have reviewed *the latest version of* these changes and I am sure that they don’t contain any code that could compromise the security of the CI infrastructure.')
string(name: 'PR_ID', defaultValue: "", description: 'The numeric ID of the pull request (from GitHub URL)')
string(name: 'BRANCH', defaultValue: 'master', description: 'Git branch to use for testing (ignore this value for PRs)')
}

stages {
stage("Setup repository") {
steps {
checkout(poll: false, scm: [
$class: 'GitSCM',
branches: [[
name: (params.PR_ID ? "pr/${params.PR_ID}/head" : params.BRANCH)
]],
userRemoteConfigs: [[
url: "https://github.com/nodejs/http-parser",
refspec: '+refs/pull/*:refs/remotes/origin/pr/* +refs/heads/*:refs/remotes/origin/*',
]]
])
}
}

stage('Setup build dependencies') {
steps {
echo "Testing: ${sh(returnStdout: true, script: 'git log -1 --oneline').trim()}"

sh 'gcc --version'
sendBuildStatus("pending", env.PR_ID, env.BUILD_URL, env.GIT_COMMIT)
}
}

stage('Run tests') {
steps {
sh 'make'
}
}
}

post {
success {
sendBuildStatus("success", env.PR_ID, env.BUILD_URL, env.GIT_COMMIT)
}

failure {
sendBuildStatus("failure", env.PR_ID, env.BUILD_URL, env.GIT_COMMIT)
}
}
}

def sendBuildStatus(status, prId, buildUrl, commit) {
if (!prId) { return }

build job: 'post-build-status-update', parameters: [
string(name: 'REPO', value: 'http-parser'),
string(name: 'IDENTIFIER', value: 'test'),
string(name: 'URL', value: buildUrl),
string(name: 'COMMIT', value: commit),
string(name: 'REF', value: "refs/pull/${env.PR_ID}/head"),
]
}