mirror of
https://github.com/overleaf/overleaf.git
synced 2025-12-05 01:10:29 +00:00
Enable Jenkins hooks for creating GitHub issues for all pipelines with owners GitOrigin-RevId: ba46db1d3137db12ee5c78f09b126fb9927d9c49
161 lines
4.5 KiB
Groovy
161 lines
4.5 KiB
Groovy
// Autogenerated by build scripts. Do not edit.
|
|
|
|
pipeline {
|
|
agent {
|
|
node {
|
|
label 'jenkins-agent-web'
|
|
customWorkspace '/workspace'
|
|
}
|
|
}
|
|
options {
|
|
timestamps()
|
|
timeout(time: 15, unit: 'MINUTES')
|
|
}
|
|
environment {
|
|
BRANCH_NAME = "${env.CHANGE_BRANCH ? env.CHANGE_BRANCH : env.BRANCH_NAME}"
|
|
JENKINS_BUILD_NUMBER = "${BUILD_NUMBER}"
|
|
DOCKER_COMPOSE_FLAGS = '-f docker-compose.ci.yml'
|
|
}
|
|
stages {
|
|
stage('Set Build Variables') {
|
|
steps {
|
|
script {
|
|
def relevantCommitHash
|
|
if (env.CHANGE_BRANCH) {
|
|
def commitExistsOnRemote = sh(script: "git branch --remotes --contains ${GIT_COMMIT}", returnStdout: true).trim()
|
|
if (commitExistsOnRemote) {
|
|
echo "PR build detected, but commit exists on remote. Using ${GIT_COMMIT}"
|
|
relevantCommitHash = "${GIT_COMMIT}"
|
|
} else {
|
|
def parentCommits = sh(script: 'git rev-parse HEAD^@', returnStdout: true).trim().split('\n')
|
|
if (parentCommits.size() >= 2) {
|
|
echo "PR build detected. Jenkins checked out a merge commit: ${GIT_COMMIT} (parents: ${parentCommits.join(', ')})"
|
|
relevantCommitHash = parentCommits[0]
|
|
echo "Using first parent (branch commit): ${relevantCommitHash}"
|
|
} else {
|
|
echo "WARN: PR build detected, but ${GIT_COMMIT} is neither a merge commit, nor does it exist on the remote."
|
|
relevantCommitHash = "${GIT_COMMIT}"
|
|
}
|
|
}
|
|
} else {
|
|
echo "Branch build detected. Using commit: ${GIT_COMMIT}"
|
|
relevantCommitHash = "${GIT_COMMIT}"
|
|
}
|
|
env.COMMIT_SHA = relevantCommitHash
|
|
env.SHORT_SHA = relevantCommitHash.take(7)
|
|
env.BUILD_NUMBER = "${env.SHORT_SHA}_${env.JENKINS_BUILD_NUMBER}"
|
|
}
|
|
}
|
|
}
|
|
stage('Stage 1') {
|
|
parallel {
|
|
stage('Build') {
|
|
steps {
|
|
dir('services/chat') {
|
|
retry(count: 3) {
|
|
sh 'make build'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Create reports folder') {
|
|
steps {
|
|
sh 'mkdir services/chat/reports'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Stage 2') {
|
|
parallel {
|
|
stage('Push Branch Image') {
|
|
steps {
|
|
dir('services/chat') {
|
|
sh 'make push_branch'
|
|
}
|
|
}
|
|
}
|
|
stage('Shellcheck') {
|
|
steps {
|
|
dir('services/chat') {
|
|
sh 'make shellcheck'
|
|
}
|
|
}
|
|
}
|
|
stage('Lint') {
|
|
steps {
|
|
dir('services/chat') {
|
|
sh 'make lint_ci'
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
recordIssues checksAnnotationScope: 'ALL', enabledForFailure: true, failOnError: true, id: 'chat-eslint', name: 'chat eslint', qualityGates: [[integerThreshold: 1, threshold: 1.0, type: 'TOTAL']], sourceCodeRetention: 'LAST_BUILD', tools: [esLint(pattern: 'services/chat/reports/eslint.json')]
|
|
}
|
|
}
|
|
}
|
|
stage('Format') {
|
|
steps {
|
|
dir('services/chat') {
|
|
sh 'make format_ci'
|
|
}
|
|
}
|
|
}
|
|
stage('Typecheck') {
|
|
steps {
|
|
dir('services/chat') {
|
|
sh 'make typecheck_ci'
|
|
}
|
|
}
|
|
}
|
|
stage('Test Unit') {
|
|
steps {
|
|
dir('services/chat') {
|
|
retry(count: 3) {
|
|
sh 'make test_unit'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Test Acceptance') {
|
|
environment {
|
|
COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance"
|
|
}
|
|
steps {
|
|
dir('services/chat') {
|
|
retry(count: 3) {
|
|
sh 'make test_acceptance'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('Push Production') {
|
|
steps {
|
|
dir('services/chat') {
|
|
sh 'make push'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
junit checksName: 'chat test results', testResults: 'services/chat/reports/junit-*.xml'
|
|
}
|
|
failure {
|
|
script {
|
|
if (env.BRANCH_NAME == 'main') {
|
|
node('built-in') {
|
|
sh '/usr/local/bin/open-gh-failure-issue --project="🥑 Core"'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
cleanup {
|
|
dir('services/chat') {
|
|
sh 'make clean'
|
|
}
|
|
sh 'make clean_jenkins -j10'
|
|
}
|
|
}
|
|
} |