Connect Your CI / Jenkins
Keep Jenkins as your pipeline engine. A credential and two curl calls report the outcome to UnityFreak so required checks gate the merge.
repo:write-scoped token, store it as a Jenkins Secret Text credential named uf-api-key.pending at the start of the pipeline and success/failure from a post { always { ... } } block.ci/tests context to Required Status Checks in the repository's UnityFreak settings.Under Settings → Personal Access Tokens, create a token scoped to repo:write — the same scope git push uses, and what authorizes posting a status.
In Manage Jenkins → Credentials, add a "Secret text" credential with ID uf-api-key holding the token from step 1. Replace the UF_OWNER/UF_REPO placeholders in the Jenkinsfile below with your repository's owner and slug (or wire them as job parameters if you reuse this pipeline across repos).
pipeline {
agent any
environment {
UF_API_KEY = credentials('uf-api-key')
UF_OWNER = 'OWNER'
UF_REPO = 'REPO'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Notify pending') {
steps {
sh '''
curl -sf -X POST \
"https://api.unityfreak.com/api/v1/repos/$UF_OWNER/$UF_REPO/statuses/$GIT_COMMIT" \
-H "X-API-Key: $UF_API_KEY" \
-H "Content-Type: application/json" \
-d '{"state":"pending","context":"ci/tests","targetUrl":"'"$BUILD_URL"'"}'
'''
}
}
stage('Test') {
steps {
sh 'npm ci && npm test'
}
}
}
post {
always {
script {
def state = currentBuild.currentResult == 'SUCCESS' ? 'success' : 'failure'
sh """
curl -sf -X POST \
"https://api.unityfreak.com/api/v1/repos/\$UF_OWNER/\$UF_REPO/statuses/\$GIT_COMMIT" \
-H "X-API-Key: \$UF_API_KEY" \
-H "Content-Type: application/json" \
-d '{"state":"${state}","context":"ci/tests","targetUrl":"'"\$BUILD_URL"'"}'
"""
}
}
}
}
The explicit checkout scm stage matters even in a multibranch/Pipeline-from-SCM job that already checks out automatically — it's what populates the $GIT_COMMIT environment variable the rest of the pipeline depends on. Pasting this as a plain "Pipeline script" job with no SCM configured leaves $GIT_COMMIT unset and every status post will 404.
In the repository's branch protection settings on UnityFreak, add ci/tests to Required Status Checks. It only appears in that picker after being reported at least once — run the pipeline above first.
post { always { } } BlockA failed sh step aborts the rest of its stage by default. Reporting the result from post { always { } } — rather than as the last step inside the Test stage — guarantees it still runs when tests fail, so the check reports failure instead of sitting on pending forever.