Skip to content

Commit 5fb1b32

Browse files
authored
Update Jenkins (#881)
* Always upload artifacts from master * Separate stable from dev builds * Support the github label 'CI/Update Submodules' * Support the github label 'CI/Upload Artifacts'
1 parent 4ceb1c1 commit 5fb1b32

File tree

1 file changed

+48
-17
lines changed

1 file changed

+48
-17
lines changed

Jenkinsfile

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pipeline {
195195
'''
196196

197197
archiveArtifacts "OMSimulator-linux-i386-*.tar.gz"
198-
stash name: 'i389-zip', includes: "OMSimulator-linux-i386-*.tar.gz"
198+
stash name: 'i386-zip', includes: "OMSimulator-linux-i386-*.tar.gz"
199199

200200
partest()
201201

@@ -404,7 +404,7 @@ EXIT /b 1
404404
when {
405405
anyOf {
406406
expression { return params.MINGW32 }
407-
expression { return params.UPLOAD_BUILD_OPENMODELICA }
407+
expression { return shouldWeUploadArtifacts() }
408408
buildingTag()
409409
}
410410
beforeAgent true
@@ -587,20 +587,20 @@ EXIT /b 1
587587
when {
588588
anyOf {
589589
buildingTag()
590-
expression { return params.UPLOAD_BUILD_OPENMODELICA }
590+
expression { return shouldWeUploadArtifacts() }
591591
}
592592
beforeAgent true
593593
}
594594
environment {
595-
EXPERIMENTAL = getExperimentalPath()
595+
DEPLOYMENT_PREFIX = getDeploymentPrefix()
596596
}
597597
agent {
598598
label 'linux'
599599
}
600600
steps {
601601
unstash name: 'amd64-zip' // includes: "OMSimulator-linux-amd64-*.tar.gz"
602602
unstash name: 'arm32-zip' // includes: "OMSimulator-linux-arm32-*.tar.gz"
603-
unstash name: 'i389-zip' // includes: "OMSimulator-linux-i386-*.tar.gz"
603+
unstash name: 'i386-zip' // includes: "OMSimulator-linux-i386-*.tar.gz"
604604
unstash name: 'mingw32-zip' // includes: "OMSimulator-mingw32-*.zip"
605605
unstash name: 'mingw64-zip' // includes: "OMSimulator-mingw64-*.zip"
606606
unstash name: 'win64-zip' // includes: "OMSimulator-win64-*.zip"
@@ -614,25 +614,25 @@ EXIT /b 1
614614
configName: 'OMSimulator',
615615
transfers: [
616616
sshTransfer(
617-
remoteDirectory: "${EXPERIMENTAL}linux-i386/",
617+
remoteDirectory: "${DEPLOYMENT_PREFIX}linux-i386/",
618618
sourceFiles: 'OMSimulator-linux-i386-*.tar.gz'),
619619
sshTransfer(
620-
remoteDirectory: "${EXPERIMENTAL}linux-arm32/",
620+
remoteDirectory: "${DEPLOYMENT_PREFIX}linux-arm32/",
621621
sourceFiles: 'OMSimulator-linux-arm32-*.tar.gz'),
622622
sshTransfer(
623-
remoteDirectory: "${EXPERIMENTAL}linux-amd64/",
623+
remoteDirectory: "${DEPLOYMENT_PREFIX}linux-amd64/",
624624
sourceFiles: 'OMSimulator-linux-amd64-*.tar.gz'),
625625
sshTransfer(
626-
remoteDirectory: "${EXPERIMENTAL}win-mingw32/",
626+
remoteDirectory: "${DEPLOYMENT_PREFIX}win-mingw32/",
627627
sourceFiles: 'OMSimulator-mingw32-*.zip'),
628628
sshTransfer(
629-
remoteDirectory: "${EXPERIMENTAL}win-mingw64/",
629+
remoteDirectory: "${DEPLOYMENT_PREFIX}win-mingw64/",
630630
sourceFiles: 'OMSimulator-mingw64-*.zip'),
631631
sshTransfer(
632-
remoteDirectory: "${EXPERIMENTAL}osx/",
632+
remoteDirectory: "${DEPLOYMENT_PREFIX}osx/",
633633
sourceFiles: 'OMSimulator-osx-*.zip'),
634634
sshTransfer(
635-
remoteDirectory: "${EXPERIMENTAL}win-msvc64/",
635+
remoteDirectory: "${DEPLOYMENT_PREFIX}win-msvc64/",
636636
sourceFiles: 'OMSimulator-win64-*.zip')
637637
]
638638
)
@@ -704,7 +704,7 @@ void buildOMS() {
704704
}
705705

706706
void submoduleNoChange(path) {
707-
if (params.SUBMODULE_UPDATE) {
707+
if (shouldWeUpdateSubmodules()) {
708708
// Don't need to check
709709
return
710710
}
@@ -715,11 +715,42 @@ void submoduleNoChange(path) {
715715
}
716716
}
717717

718-
def getExperimentalPath() {
719-
if (env.CHANGE_ID) {
718+
def isPR() {
719+
return env.CHANGE_ID ? true : false
720+
}
721+
722+
def isTag() {
723+
return env.TAG_NAME ? true : false
724+
}
725+
726+
def getDeploymentPrefix() {
727+
if (isPR()) {
720728
return "experimental/pr-${env.CHANGE_ID}/"
721729
}
722-
else {
723-
return "./" // We can't use an empty string due to an stupid Jenkins bug
730+
if (isTag()) {
731+
return "stable/"
732+
}
733+
return "dev/"
734+
}
735+
736+
def shouldWeUploadArtifacts() {
737+
if (isPR()) {
738+
if (pullRequest.labels.contains("CI/Upload Artifacts")) {
739+
return true
740+
}
741+
return params.UPLOAD_BUILD_OPENMODELICA
742+
}
743+
if (env.GIT_BRANCH == "master") {
744+
return true
745+
}
746+
return false
747+
}
748+
749+
def shouldWeUpdateSubmodules() {
750+
if (isPR()) {
751+
if (pullRequest.labels.contains("CI/Update Submodules")) {
752+
return true
753+
}
724754
}
755+
return params.SUBMODULE_UPDATE
725756
}

0 commit comments

Comments
 (0)