2025-tombutcher-ui/Jenkinsfile
Tom Butcher a7b5408c5e
Some checks failed
tombutcher.work/tombutcher-ui/pipeline/head There was a failure building this commit
Install node
2025-04-06 21:15:53 +01:00

69 lines
1.5 KiB
Groovy

pipeline {
agent any
environment {
NODE_ENV = 'production'
CLOUDFLARE_ACCOUNT_ID = credentials('cloudflare-account-id')
CLOUDFLARE_API_TOKEN = credentials('cloudflare-api-token')
PROJECT_NAME = 'tombutcher-ui'
NODE_VERSION = '23.11.0'
}
stages {
stage('Install Node.js') {
steps {
script {
// Install NVM and Node.js if not already installed
sh ''
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install $NODE_VERSION
nvm use $NODE_VERSION
nvm alias default $NODE_VERSION
''
}
}
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('Install dependencies') {
steps {
sh 'npm install'
}
}
stage('Build') {
steps {
sh 'npm run build'
}
}
stage('Deploy to Cloudflare Pages') {
steps {
sh '''
npm install -g wrangler
wrangler pages deploy ./build \
--project-name $PROJECT_NAME \
--branch main \
--account-id $CLOUDFLARE_ACCOUNT_ID \
--api-token $CLOUDFLARE_API_TOKEN
'''
}
}
}
post {
failure {
echo 'Build or deployment failed.'
}
success {
echo 'Successfully deployed to Cloudflare Pages.'
}
}
}