Skip to content

Commit

Permalink
fix: don't run Jenkins on doc/ branches and PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybellwood committed Mar 26, 2024
1 parent 0e2b236 commit 545aa0a
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
def skipRemainingStages = false

pipeline {
agent { label 'lagoon' }
environment {
Expand All @@ -20,6 +22,20 @@ pipeline {
sh 'env'
}
}
stage ('skip on docs commit') {
when {
anyOf {
changeRequest branch: 'docs\\/.*', comparator: 'REGEXP'
branch pattern: "docs\\/.*", comparator: "REGEXP"
}
}
steps {
script {
skipRemainingStages = true
echo "Docs only update, no build needed."
}
}
}
// in order to have the newest images from upstream (with all the security
// updates) we clean our local docker cache on tag deployments
// we don't do this all the time to still profit from image layer caching
Expand All @@ -28,12 +44,20 @@ pipeline {
stage ('clean docker image cache') {
when {
buildingTag()
expression {
!skipRemainingStages
}
}
steps {
sh script: "docker image prune -af", label: "Pruning images"
}
}
stage ('build and push images') {
when {
expression {
!skipRemainingStages
}
}
environment {
PASSWORD = credentials('amazeeiojenkins-dockerhub-password')
}
Expand All @@ -46,11 +70,21 @@ pipeline {
}
}
stage ('show trivy scan results') {
when {
expression {
!skipRemainingStages
}
}
steps {
sh script: "cat scan.txt", label: "Display scan results"
}
}
stage ('setup test cluster') {
when {
expression {
!skipRemainingStages
}
}
parallel {
stage ('0: setup test cluster') {
steps {
Expand All @@ -72,6 +106,11 @@ pipeline {
}
}
stage ('run first test suite') {
when {
expression {
!skipRemainingStages
}
}
parallel {
stage ('1: run first test suite') {
steps {
Expand Down Expand Up @@ -106,6 +145,11 @@ pipeline {
}
}
stage ('run second test suite') {
when {
expression {
!skipRemainingStages
}
}
parallel {
stage ('2: run second test suite') {
steps {
Expand All @@ -126,6 +170,11 @@ pipeline {
}
}
stage ('run third test suite') {
when {
expression {
!skipRemainingStages
}
}
parallel {
stage ('3: run third test suite') {
steps {
Expand All @@ -146,11 +195,14 @@ pipeline {
}
}
stage ('push images to testlagoon/* with :latest tag') {
when {
when {
branch 'main'
not {
environment name: 'SKIP_IMAGE_PUBLISH', value: 'true'
}
expression {
!skipRemainingStages
}
}
environment {
PASSWORD = credentials('amazeeiojenkins-dockerhub-password')
Expand All @@ -166,6 +218,9 @@ pipeline {
not {
environment name: 'SKIP_IMAGE_PUBLISH', value: 'true'
}
expression {
!skipRemainingStages
}
}
environment {
TOKEN = credentials('git-amazeeio-helmfile-ci-trigger')
Expand All @@ -180,6 +235,9 @@ pipeline {
not {
environment name: 'SKIP_IMAGE_PUBLISH', value: 'true'
}
expression {
!skipRemainingStages
}
}
environment {
PASSWORD = credentials('amazeeiojenkins-dockerhub-password')
Expand All @@ -195,6 +253,9 @@ pipeline {
branch 'testing/scans'
buildingTag()
}
expression {
!skipRemainingStages
}
}
steps {
sh script: 'make scan-images', label: "perform scan routines"
Expand Down

0 comments on commit 545aa0a

Please sign in to comment.