Skip to content

Commit e9381eb

Browse files
committed
ci: deploying windows generates a chocolatey config file
1 parent 08a2e21 commit e9381eb

File tree

1 file changed

+79
-20
lines changed

1 file changed

+79
-20
lines changed

vars/runJenkinsPipeline.groovy

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ def getStandAloneStorageServers(){
99
}
1010
}
1111

12+
def createChocolateyConfigFile(configJsonFile, installerPackage, url){
13+
def deployJsonMetadata = [
14+
"PackageVersion": readTOML( file: 'pyproject.toml')['project'].version,
15+
"DownloadUrl": url,
16+
"PackageFile": installerPackage.name,
17+
"Sha256": sha256(installerPackage.path),
18+
"TabCompletionPowershellModule": "${installerPackage.name.take(installerPackage.name.lastIndexOf('.'))}\\extras\\cli_completion\\powershell\\GalateaArgumentCompleter.psm1"
19+
20+
]
21+
writeJSON( json: deployJsonMetadata, file: configJsonFile, pretty: 2)
22+
}
23+
1224
def deployStandalone(glob, url) {
1325
script{
1426
findFiles(glob: glob).each{
@@ -25,6 +37,20 @@ def deployStandalone(glob, url) {
2537
}
2638
}
2739

40+
def deploySingleStandalone(file, url, authentication) {
41+
script{
42+
try{
43+
def encodedUrlFileName = new URI(null, null, file.name, null).toASCIIString()
44+
def newUrl = "${url}/${encodedUrlFileName}"
45+
def putResponse = httpRequest authentication: authentication, httpMode: 'PUT', uploadFile: file.path, url: "${newUrl}", wrapAsMultipart: false
46+
return newUrl
47+
} catch(Exception e){
48+
echo "${e}"
49+
throw e;
50+
}
51+
}
52+
}
53+
2854
def getToxEnvs(){
2955
node('docker && windows'){
3056
docker.image('python').inside("--mount type=volume,source=uv_python_install_dir,target=${env.UV_PYTHON_INSTALL_DIR}"){
@@ -74,7 +100,6 @@ def call(){
74100
]
75101
)
76102
)
77-
standaloneVersions = []
78103
pipeline {
79104
agent none
80105
parameters{
@@ -656,9 +681,6 @@ def call(){
656681
success{
657682
archiveArtifacts artifacts: 'dist/*.tar.gz', fingerprint: true
658683
stash includes: 'dist/*.tar.gz', name: 'APPLE_APPLICATION_X86_64'
659-
script{
660-
standaloneVersions << 'APPLE_APPLICATION_X86_64'
661-
}
662684
}
663685
cleanup{
664686
cleanWs(patterns: [
@@ -710,9 +732,6 @@ def call(){
710732
success{
711733
archiveArtifacts artifacts: 'dist/*.tar.gz', fingerprint: true
712734
stash includes: 'dist/*.tar.gz', name: 'APPLE_APPLICATION_ARM64'
713-
script{
714-
standaloneVersions << 'APPLE_APPLICATION_ARM64'
715-
}
716735
}
717736
cleanup{
718737
cleanWs(patterns: [
@@ -767,15 +786,10 @@ def call(){
767786
tee('reports/windows_cpack.log'){
768787
bat(script: 'contrib/create_windows_distrib.bat')
769788
}
789+
archiveArtifacts artifacts: 'dist/*.zip', fingerprint: true
790+
stash includes: 'dist/*.zip', name: 'WINDOWS_APPLICATION_X86_64'
770791
}
771792
post{
772-
success{
773-
archiveArtifacts artifacts: 'dist/*.zip', fingerprint: true
774-
stash includes: 'dist/*.zip', name: 'WINDOWS_APPLICATION_X86_64'
775-
script{
776-
standaloneVersions << 'WINDOWS_APPLICATION_X86_64'
777-
}
778-
}
779793
always{
780794
recordIssues(
781795
sourceCodeRetention: 'LAST_BUILD',
@@ -854,15 +868,60 @@ def call(){
854868
string defaultValue: "galatea/${get_version()}", description: 'subdirectory to store artifact', name: 'archiveFolder'
855869
}
856870
}
857-
stages{
858-
stage('Deploy Standalone Applications'){
871+
parallel{
872+
stage('Deploy Standalone Applications: Windows x86_64'){
859873
agent any
874+
when{
875+
equals expected: true, actual: params.PACKAGE_STANDALONE_WINDOWS_INSTALLER
876+
beforeAgent true
877+
}
878+
environment{
879+
GENERATED_CHOCOLATEY_CONFIG_FILE='dist/chocolatey/config.json'
880+
}
860881
steps{
861882
script{
862-
standaloneVersions.each{
863-
unstash "${it}"
864-
}
865-
deployStandalone('dist/*.zip', "${SERVER_URL}/${archiveFolder}")
883+
unstash 'WINDOWS_APPLICATION_X86_64'
884+
def deploymentFile = findFiles(glob: 'dist/*.zip')[0]
885+
def deployedUrl = deploySingleStandalone(deploymentFile, "${SERVER_URL}/${archiveFolder}", NEXUS_CREDS)
886+
createChocolateyConfigFile(env.GENERATED_CHOCOLATEY_CONFIG_FILE, deploymentFile, deployedUrl)
887+
archiveArtifacts artifacts: env.GENERATED_CHOCOLATEY_CONFIG_FILE
888+
echo "Deployed ${deploymentFile} to ${deployedUrl} -> SHA256: ${sha256(deploymentFile.path)}"
889+
}
890+
}
891+
post{
892+
success{
893+
echo "Use ${env.GENERATED_CHOCOLATEY_CONFIG_FILE} for deploying to Chocolatey with https://github.com/UIUCLibrary/chocolatey-hosted-public.git. Found in the artifacts for this build."
894+
echo "${readFile(env.GENERATED_CHOCOLATEY_CONFIG_FILE)}"
895+
}
896+
}
897+
}
898+
stage('Deploy Standalone Applications: MacOS ARM64'){
899+
agent any
900+
when{
901+
equals expected: true, actual: params.PACKAGE_MAC_OS_STANDALONE_ARM64
902+
beforeAgent true
903+
}
904+
steps{
905+
script{
906+
unstash 'APPLE_APPLICATION_ARM64'
907+
def deploymentFile = findFiles(glob: 'dist/*.tar.gz')[0]
908+
def deployedUrl = deploySingleStandalone(deploymentFile, "${SERVER_URL}/${archiveFolder}", NEXUS_CREDS)
909+
echo "Deployed ${deploymentFile} to ${deployedUrl} -> SHA256: ${sha256(deploymentFile.path)}"
910+
}
911+
}
912+
}
913+
stage('Deploy Standalone Applications: MacOS X86_64'){
914+
agent any
915+
when{
916+
equals expected: true, actual: params.PACKAGE_MAC_OS_STANDALONE_X86_64
917+
beforeAgent true
918+
}
919+
steps{
920+
script{
921+
unstash 'APPLE_APPLICATION_X86_64'
922+
def deploymentFile = findFiles(glob: 'dist/*.tar.gz')[0]
923+
def deployedUrl = deploySingleStandalone(deploymentFile, "${SERVER_URL}/${archiveFolder}", NEXUS_CREDS)
924+
echo "Deployed ${deploymentFile} to ${deployedUrl} -> SHA256: ${sha256(deploymentFile.path)}"
866925
}
867926
}
868927
}

0 commit comments

Comments
 (0)