Jenkins Integration
Jenkins shared library
GOVERN provides a Jenkins shared library. Add it in Manage Jenkins → Configure System → Global Pipeline Libraries:
Name: governDefault version: mainRetrieval method: Modern SCMRepository URL: https://github.com/archetypal-ai/govern-jenkins-libraryDeclarative pipeline
// Jenkinsfile@Library('govern') _
pipeline { agent any
environment { GOVERN_API_KEY = credentials('govern-api-key') GOVERN_ORG_ID = credentials('govern-org-id') }
stages { stage('Test') { steps { sh 'npm ci && npm test' } }
stage('GOVERN') { steps { governAssess( model: 'claude-sonnet-4-20250514', testPrompts: 'tests/govern/prompts.json', failOn: 'flag', outputFormat: 'junit' ) } post { always { junit 'govern-results.xml' } } }
stage('Deploy') { when { branch 'main' expression { currentBuild.result == 'SUCCESS' } } steps { sh './deploy.sh' } } }}Scripted pipeline
// Jenkinsfile (scripted)node { checkout scm
withCredentials([ string(credentialsId: 'govern-api-key', variable: 'GOVERN_API_KEY'), string(credentialsId: 'govern-org-id', variable: 'GOVERN_ORG_ID') ]) { stage('GOVERN Assessment') { sh """ govern assess \\ --batch-file tests/govern/prompts.json \\ --model claude-sonnet-4-20250514 \\ --fail-on-flag \\ --output json > govern-results.json """ archiveArtifacts artifacts: 'govern-results.json' } }}Installing the CLI in Jenkins
stage('Setup') { steps { sh 'npm install -g @archetypal-ai/govern-cli' sh 'govern --version' }}Or use the Docker agent:
pipeline { agent { docker { image 'archetypal/govern-cli:latest' } } stages { stage('GOVERN') { steps { sh 'govern assess --batch-file tests/govern/prompts.json ...' } } }}Credentials setup
- Navigate to Manage Jenkins → Credentials → System → Global credentials
- Add credential → Secret text
- ID:
govern-api-key, Secret:gvn_live_xxxx - Repeat for
govern-org-id
Never put API keys in Jenkinsfiles. Always use Jenkins credentials binding.