2024-08-04 21:07:12 +00:00
|
|
|
pipeline {
|
|
|
|
|
agent any
|
2024-08-04 21:18:56 +00:00
|
|
|
environment {
|
|
|
|
|
MAX_RETRIES = 5
|
|
|
|
|
}
|
2024-08-04 21:07:12 +00:00
|
|
|
stages {
|
|
|
|
|
stage('Gradle') {
|
|
|
|
|
steps {
|
2024-08-04 21:18:56 +00:00
|
|
|
script {
|
|
|
|
|
def retryCount = 0
|
|
|
|
|
def success = false
|
|
|
|
|
|
|
|
|
|
// Clean npm cache and try normal install and npm ci once
|
2024-08-10 01:21:16 +00:00
|
|
|
try {
|
|
|
|
|
sh 'npm cache clean --force'
|
|
|
|
|
} catch (Exception e0) {
|
|
|
|
|
echo 'npm cache clean --force failed trying more things'
|
|
|
|
|
}
|
2024-08-04 21:18:56 +00:00
|
|
|
try {
|
|
|
|
|
sh 'npm install'
|
|
|
|
|
success = true
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
echo "npm install failed, trying npm ci..."
|
|
|
|
|
try {
|
|
|
|
|
sh 'npm ci'
|
|
|
|
|
success = true
|
|
|
|
|
} catch (Exception e2) {
|
|
|
|
|
echo "npm ci failed, proceeding to retry with --legacy-peer-deps and --force..."
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Retry with --legacy-peer-deps and --force if necessary
|
|
|
|
|
while (retryCount < MAX_RETRIES.toInteger() && !success) {
|
|
|
|
|
try {
|
|
|
|
|
sh 'npm install --legacy-peer-deps'
|
|
|
|
|
success = true
|
|
|
|
|
} catch (Exception e3) {
|
|
|
|
|
try {
|
|
|
|
|
sh 'npm install --force'
|
|
|
|
|
success = true
|
|
|
|
|
} catch (Exception e4) {
|
|
|
|
|
retryCount++
|
|
|
|
|
echo "Retry ${retryCount}/${MAX_RETRIES} failed"
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-10 01:19:26 +00:00
|
|
|
try {
|
|
|
|
|
sh 'npm install --legacy-peer-deps --force'
|
|
|
|
|
success = true
|
|
|
|
|
} catch (Exception e4) {
|
|
|
|
|
echo "npm install --legacy-peer-deps --force failed"
|
|
|
|
|
}
|
2024-08-04 21:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!success) {
|
|
|
|
|
error "Failed to install dependencies after ${MAX_RETRIES} attempts"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sh 'npm run build'
|
|
|
|
|
}
|
2024-08-04 21:07:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
stage('Archive') {
|
|
|
|
|
steps {
|
|
|
|
|
archiveArtifacts artifacts: 'build/**', followSymlinks: false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
stage('discord') {
|
2024-08-08 18:32:43 +00:00
|
|
|
when {
|
2024-08-08 18:38:05 +00:00
|
|
|
anyOf {
|
|
|
|
|
branch 'main'
|
|
|
|
|
branch 'master'
|
|
|
|
|
}
|
2024-08-08 18:32:43 +00:00
|
|
|
}
|
2024-08-04 21:07:12 +00:00
|
|
|
steps {
|
|
|
|
|
discordSend description: "Build: ${BUILD_NUMBER}", showChangeset: true, result: currentBuild.currentResult, title: currentBuild.fullProjectName, webhookURL: env.discordwebhook
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-08-04 21:18:56 +00:00
|
|
|
}
|