diff --git a/Jenkinsfile b/Jenkinsfile index 719d95f..847f2e7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,30 +47,6 @@ pipeline { } } - stage('Deploy PR to preview site') { - when { - allOf{ - changeRequest target: 'main' - // Only deploy from infra.ci.jenkins.io - expression { infra.isInfra() } - } - } - environment { - NETLIFY_AUTH_TOKEN = credentials('netlify-auth-token') - } - steps { - sh 'netlify-deploy --draft=true --siteName "stats-jenkins-io" --title "Preview deploy for ${CHANGE_ID}" --alias "deploy-preview-${CHANGE_ID}" -d ./dist' - } - post { - success { - recordDeployment('jenkins-infra', 'stats.jenkins.io', pullRequest.head, 'success', "https://deploy-preview-${CHANGE_ID}--stats-jenkins-io.netlify.app") - } - failure { - recordDeployment('jenkins-infra', 'stats.jenkins.io', pullRequest.head, 'failure', "https://deploy-preview-${CHANGE_ID}--stats-jenkins-io.netlify.app") - } - } - } - stage('Deploy to production') { when { allOf{ diff --git a/Jenkinsfile_previews b/Jenkinsfile_previews new file mode 100644 index 0000000..9ee1783 --- /dev/null +++ b/Jenkinsfile_previews @@ -0,0 +1,69 @@ +pipeline { + options { + timeout(time: 60, unit: 'MINUTES') + ansiColor('xterm') + disableConcurrentBuilds(abortPrevious: true) + buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '5', numToKeepStr: '5') + } + + agent { + label 'linux-arm64-docker || arm64linux' + } + + stages { + stage('Install dependencies') { + when { + allOf{ + changeRequest target: 'main' + // Only deploy from infra.ci.jenkins.io + expression { infra.isInfra() } + } + } + steps { + sh ''' + asdf install + npm install + ''' + } + } + + stage('Build') { + when { + allOf{ + changeRequest target: 'main' + // Only deploy from infra.ci.jenkins.io + expression { infra.isInfra() } + } + } + steps { + sh ''' + npm run build + ''' + } + } + + stage('Deploy PR to preview site') { + when { + allOf{ + changeRequest target: 'main' + // Only deploy from infra.ci.jenkins.io + expression { infra.isInfra() } + } + } + environment { + NETLIFY_AUTH_TOKEN = credentials('netlify-auth-token') + } + steps { + sh 'netlify-deploy --draft=true --siteName "stats-jenkins-io" --title "Preview deploy for ${CHANGE_ID}" --alias "deploy-preview-${CHANGE_ID}" -d ./dist' + } + post { + success { + recordDeployment('jenkins-infra', 'stats.jenkins.io', pullRequest.head, 'success', "https://deploy-preview-${CHANGE_ID}--stats-jenkins-io.netlify.app") + } + failure { + recordDeployment('jenkins-infra', 'stats.jenkins.io', pullRequest.head, 'failure', "https://deploy-preview-${CHANGE_ID}--stats-jenkins-io.netlify.app") + } + } + } + } +}