Jenkins¶
You can use private Capawesome npm packages within your Jenkins pipelines by configuring the Capawesome npm registry. This guide shows you how to set up authentication to access the private packages from the Capawesome Insiders program.
Preparation¶
Create Jenkins Credentials¶
Get your license key and add it to your Jenkins instance as a secret text credential with the ID CAPAWESOME_NPM_REGISTRY_TOKEN
as described in Using credentials.
Keep your license key secure
Never commit your license key directly to your repository and always use environment variables to store sensitive information like authentication tokens.
Pipeline Configuration¶
Configure the npm registry¶
Add the following script to your Jenkins pipeline before installing npm dependencies:
withCredentials([string(credentialsId: 'CAPAWESOME_NPM_REGISTRY_TOKEN', variable: 'CAPAWESOME_NPM_REGISTRY_TOKEN')]) {
sh '''
echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc
echo "//npm.registry.capawesome.io/:_authToken=${CAPAWESOME_NPM_REGISTRY_TOKEN}" >> .npmrc
'''
}
This will automatically configure npm to use the Capawesome registry for @capawesome-team
packages during Jenkins builds.
Example¶
Here's a complete example of a Jenkins pipeline that builds an Ionic app using private Capawesome packages:
pipeline {
agent any
environment {
NODE_VERSION = '20'
}
stages {
stage('Setup') {
steps {
// Install Node.js
sh '''
curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | sudo -E bash -
sudo apt-get install -y nodejs
'''
}
}
stage('Configure Registry') {
steps {
withCredentials([string(credentialsId: 'CAPAWESOME_NPM_REGISTRY_TOKEN', variable: 'CAPAWESOME_NPM_REGISTRY_TOKEN')]) {
sh '''
echo "@capawesome-team:registry=https://npm.registry.capawesome.io" >> .npmrc
echo "//npm.registry.capawesome.io/:_authToken=${CAPAWESOME_NPM_REGISTRY_TOKEN}" >> .npmrc
'''
}
}
}
stage('Install Dependencies') {
steps {
sh 'npm ci'
}
}
stage('Build') {
steps {
sh '''
npx cap sync
npm run build
'''
}
}
}
post {
always {
// Clean up .npmrc file
sh 'rm -f .npmrc'
}
}
}