diff --git a/Jenkinsfile b/Jenkinsfile index fbace3e..757fb30 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,53 +6,47 @@ pipeline { CLOUDFLARE_ACCOUNT_ID = credentials('cloudflare-account-id') CLOUDFLARE_API_TOKEN = credentials('cloudflare-api-token') PROJECT_NAME = 'tombutcher-ui' - NODE_VERSION = '23.11.0' + } + + tools { + nodejs 'Node16' // This should match the name of your NodeJS installation in Jenkins tools } 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 + checkout scm // Checkout the repository } } stage('Install dependencies') { steps { - sh 'npm install' + script { + sh 'npm install' // Install project dependencies + } } } stage('Build') { steps { - sh 'npm run build' + script { + sh 'npm run build' // Build the project + } } } 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 - ''' + script { + 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 + ''' + } } } }