-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jenkinsfile: update with conditional steps
Signed-off-by: markoburcul <[email protected]>
- Loading branch information
1 parent
252b462
commit 7ea8436
Showing
1 changed file
with
84 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
#!/usr/bin/env groovy | ||
library '[email protected]' | ||
library '[email protected]' | ||
|
||
def changesDetected = false | ||
|
||
pipeline { | ||
agent { label 'linux' } | ||
|
@@ -27,47 +29,108 @@ pipeline { | |
} | ||
|
||
stages { | ||
stage('Check changes') { | ||
when { | ||
changeset pattern: "apps/connector/**", comparator: "GLOB" | ||
} | ||
steps { | ||
script { | ||
changesDetected = true | ||
} | ||
} | ||
} | ||
stage('Install') { | ||
steps { script { | ||
nix.shell('yarn install --frozen-lockfile', pure: false) | ||
} } | ||
when { | ||
expression { changesDetected } | ||
} | ||
steps { | ||
dir("${env.WORKSPACE}/apps/connector") { | ||
script { | ||
nix.shell( | ||
'yarn install --frozen-lockfile', | ||
pure: false, | ||
entryPoint: "${env.WORKSPACE}/apps/connector/shell.nix" | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Build') { | ||
steps { script { | ||
nix.shell('yarn build:chrome', pure: false) | ||
} } | ||
when { | ||
expression { changesDetected } | ||
} | ||
steps { | ||
dir("${env.WORKSPACE}/apps/connector") { | ||
script { | ||
nix.shell( | ||
'yarn build:chrome', | ||
pure: false, | ||
entryPoint: "${env.WORKSPACE}/apps/connector/shell.nix" | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
stage('Zip') { | ||
when { | ||
expression { changesDetected } | ||
} | ||
steps { | ||
zip( | ||
zipFile: env.ZIP_NAME, | ||
dir: 'build/chrome-mv3-prod', | ||
archive: false, | ||
) | ||
dir("${env.WORKSPACE}/apps/connector") { | ||
zip( | ||
zipFile: env.ZIP_NAME, | ||
dir: 'build/chrome-mv3-prod', | ||
archive: false, | ||
) | ||
} | ||
} | ||
} | ||
|
||
stage('Archive') { | ||
when { | ||
expression { changesDetected } | ||
} | ||
steps { | ||
archiveArtifacts( | ||
artifacts: env.ZIP_NAME, | ||
fingerprint: true, | ||
) | ||
dir("${env.WORKSPACE}/apps/connector") { | ||
archiveArtifacts( | ||
artifacts: env.ZIP_NAME, | ||
fingerprint: true, | ||
) | ||
} | ||
} | ||
} | ||
|
||
stage('Upload') { | ||
steps { script { | ||
env.PKG_URL = s5cmd.upload(env.ZIP_NAME) | ||
} } | ||
when { | ||
expression { changesDetected } | ||
} | ||
steps { | ||
dir("${env.WORKSPACE}/apps/connector") { | ||
script { | ||
env.PKG_URL = s5cmd.upload(env.ZIP_NAME) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
post { | ||
success { script { github.notifyPR(true) } } | ||
failure { script { github.notifyPR(false) } } | ||
success { | ||
script { | ||
if(changesDetected) { | ||
github.notifyPR(true) | ||
} | ||
} | ||
} | ||
success { | ||
script { | ||
if(changesDetected) { | ||
github.notifyPR(false) | ||
} | ||
} | ||
} | ||
cleanup { cleanWs() } | ||
} | ||
} |