jenkinsfile: update with conditional steps

Signed-off-by: markoburcul <marko@status.im>
This commit is contained in:
markoburcul 2024-10-11 12:10:36 +02:00
parent 252b462b71
commit 7ea84361a5
No known key found for this signature in database
GPG Key ID: FC4CD2F9A040D54A
1 changed files with 84 additions and 21 deletions

View File

@ -1,5 +1,7 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.9.1' library 'status-jenkins-lib@v1.9.11'
def changesDetected = false
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }
@ -27,20 +29,56 @@ pipeline {
} }
stages { stages {
stage('Check changes') {
when {
changeset pattern: "apps/connector/**", comparator: "GLOB"
}
steps {
script {
changesDetected = true
}
}
}
stage('Install') { stage('Install') {
steps { script { when {
nix.shell('yarn install --frozen-lockfile', pure: false) 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') { stage('Build') {
steps { script { when {
nix.shell('yarn build:chrome', pure: false) 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') { stage('Zip') {
when {
expression { changesDetected }
}
steps { steps {
dir("${env.WORKSPACE}/apps/connector") {
zip( zip(
zipFile: env.ZIP_NAME, zipFile: env.ZIP_NAME,
dir: 'build/chrome-mv3-prod', dir: 'build/chrome-mv3-prod',
@ -48,26 +86,51 @@ pipeline {
) )
} }
} }
}
stage('Archive') { stage('Archive') {
when {
expression { changesDetected }
}
steps { steps {
dir("${env.WORKSPACE}/apps/connector") {
archiveArtifacts( archiveArtifacts(
artifacts: env.ZIP_NAME, artifacts: env.ZIP_NAME,
fingerprint: true, fingerprint: true,
) )
} }
} }
}
stage('Upload') { stage('Upload') {
steps { script { when {
expression { changesDetected }
}
steps {
dir("${env.WORKSPACE}/apps/connector") {
script {
env.PKG_URL = s5cmd.upload(env.ZIP_NAME) env.PKG_URL = s5cmd.upload(env.ZIP_NAME)
} } }
}
}
} }
} }
post { post {
success { script { github.notifyPR(true) } } success {
failure { script { github.notifyPR(false) } } script {
if(changesDetected) {
github.notifyPR(true)
}
}
}
success {
script {
if(changesDetected) {
github.notifyPR(false)
}
}
}
cleanup { cleanWs() } cleanup { cleanWs() }
} }
} }