diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..11403bd --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,52 @@ +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' + } + + stages { + 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.' + } + } +}