Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
39b78cc0
Commit
39b78cc0
authored
11 years ago
by
cramakri
Browse files
Options
Downloads
Patches
Plain Diff
SWE-21 SP-638 : Script to get current installer from hudson
SVN: 29155
parent
fb30b4bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis_all/source/python/download_installer.py
+86
-0
86 additions, 0 deletions
openbis_all/source/python/download_installer.py
with
86 additions
and
0 deletions
openbis_all/source/python/download_installer.py
0 → 100755
+
86
−
0
View file @
39b78cc0
#!/usr/bin/env python
"""
Download the latest installer from the ci server
This script is used in the stage environment to retrieve the current installer.
"""
import
subprocess
import
json
import
os.path
import
glob
build_server
=
"
ci
"
dest_dir
=
os
.
path
.
expanduser
(
"
~
"
)
server_url
=
'
http://localhost:8090
'
def
run_cmd
(
cmd
):
print
(
"
"
.
join
(
cmd
))
print
(
"
\n
"
)
return
subprocess
.
check_output
(
cmd
)
def
get_files_ssh
(
proj_name
,
extension
):
# configuration -- server name and location of artifacts
artifacts_folder
=
"
hudson/jobs
"
last_build_folder
=
"
%(artifacts_folder)s/%(proj_name)s/lastSuccessful/archive/_main/targets/dist
"
%
vars
()
list_cmd
=
"
ls -1 %s | sort | tail -1
"
%
last_build_folder
server
=
build_server
last_build_cmd
=
"
ssh -T %(server)s
'
%(list_cmd)s
'"
%
vars
()
last_build
=
run_cmd
(
last_build_cmd
)
msg
=
"
Fetching artificts for %s : %s
\n
"
%
(
proj_name
,
last_build
)
print
(
msg
)
output_dir
=
dest_dir
retrieve_files_cmd
=
"
scp %(server)s:%(last_build_folder)s/*.%(extension)s %(output_dir)s/
"
%
vars
()
run_cmd
(
retrieve_files_cmd
)
def
get_artifacts_list
(
proj_name
):
build_info_cmd
=
[
"
ssh
"
,
"
-T
"
,
build_server
,
"
curl
"
,
"
-s
"
,
"
%s/job/%s/lastSuccessfulBuild/api/json
"
%
(
server_url
,
proj_name
)]
json_string
=
run_cmd
(
build_info_cmd
)
build_info
=
json
.
loads
(
json_string
)
artifacts
=
build_info
[
"
artifacts
"
]
return
artifacts
def
get_artifact
(
proj_name
,
artifact
):
# Could use curl to retrieve the artifact, but this is complicated. Easier to just use scp...
# curl_cmd = ["ssh", "-T", build_server, "curl", "-s" "%s/job/%s/lastSuccessfulBuild/artifact/%s" % (server_url, proj_name, artifact["relativePath"])]
# print("Getting artifact: " + artifact["fileName"])
artifacts_folder
=
"
hudson/jobs
"
server_file
=
"
%s:%s/%s/lastSuccessful/archive/%s
"
%
(
build_server
,
artifacts_folder
,
proj_name
,
artifact
[
"
relativePath
"
])
local_file
=
dest_dir
dl_cmd
=
[
"
scp
"
,
server_file
,
dest_dir
]
run_cmd
(
dl_cmd
)
def
get_files_rest
(
proj_name
,
extension
):
artifacts
=
get_artifacts_list
(
proj_name
)
artifact_to_get
=
None
for
artifact
in
artifacts
:
if
artifact
[
"
fileName
"
].
endswith
(
extension
):
artifact_to_get
=
artifact
break
if
artifact_to_get
is
None
:
return
get_artifact
(
proj_name
,
artifact_to_get
)
def
get_files
(
proj_name
,
extension
):
get_files_rest
(
proj_name
,
extension
)
def
clean_installer_dir
():
files_to_delete
=
glob
.
glob
(
os
.
path
.
join
(
dest_dir
,
"
openBIS-installation-standard-technologies-*-*.tar.gz
"
))
if
len
(
files_to_delete
)
<
1
:
return
print
(
"
Removing old installers :
"
+
"
,
"
.
join
(
files_to_delete
))
for
file_to_delete
in
files_to_delete
:
os
.
remove
(
file_to_delete
)
def
get_files_from_server
():
get_files
(
"
installation
"
,
"
tar.gz
"
)
# # # # # # # # # # # # # # # # # # # # # # # # #
# The Script
clean_installer_dir
()
get_files_from_server
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment