Secure your Jenkins pipelines with XtraSecurity.
xtra-api-keysk_live_xxxxtrasecurity-api-keypipeline {
agent any
environment {
XTRA_KEY = credentials('xtrasecurity-api-key')
}
stages {
stage('Get Secrets') {
steps {
sh '''
npm install -g @xtrasecurity/cli
xtra auth --username $XTRA_KEY_USR --password $XTRA_KEY_PSW
export DATABASE_URL=$(xtra get database_url)
export API_KEY=$(xtra get api_key)
echo "Secrets loaded"
'''
}
}
stage('Deploy') {
steps {
sh 'npm run deploy'
}
}
}
}
node {
withCredentials([usernamePassword(credentialsId: 'xtrasecurity-api-key',
usernameVariable: 'XTRA_USER',
passwordVariable: 'XTRA_PASS')]) {
stage('Build') {
sh '''
npm install -g @xtrasecurity/cli
xtra auth --username $XTRA_USER --password $XTRA_PASS
export DB_URL=$(xtra get db_url)
npm run build
'''
}
stage('Deploy') {
sh 'npm run deploy'
}
}
}
Create vars/xtraSecrets.groovy:
def call(Map config, Closure body) {
withCredentials([usernamePassword(credentialsId: 'xtrasecurity-api-key',
usernameVariable: 'XTRA_USER',
passwordVariable: 'XTRA_PASS')]) {
sh '''
npm install -g @xtrasecurity/cli
xtra auth --username $XTRA_USER --password $XTRA_PASS
xtra export --format env > .env.${BUILD_NUMBER}
'''
body()
}
}
Use in pipeline:
xtraSecrets {
stage('Deploy') {
sh 'npm run deploy'
}
}
Complete guide to integrating XtraSecurity with GitHub Actions. Secure your CI/CD pipeline by fetching secrets from XtraSecurity in GitHub workflows.
Integrate XtraSecurity with Docker and Docker Compose. Securely manage container secrets without hardcoding in Dockerfile.
Use XtraSecurity as a secrets provider in Kubernetes. External Secrets Operator integration for automatic secret syncing.