Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
86972543
Commit
86972543
authored
Aug 02, 2016
by
David McMahon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add update_job_result_cache() to uploader for storing last 200 results in a single file.
parent
d2c17c7c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
11 deletions
+62
-11
upload-to-gcs.sh
hack/jenkins/upload-to-gcs.sh
+62
-11
No files found.
hack/jenkins/upload-to-gcs.sh
View file @
86972543
...
@@ -63,21 +63,27 @@ readonly gcs_acl="public-read"
...
@@ -63,21 +63,27 @@ readonly gcs_acl="public-read"
readonly
results_url
=
${
gcs_build_path
//
"gs:/"
/
"https://console.cloud.google.com/storage/browser"
}
readonly
results_url
=
${
gcs_build_path
//
"gs:/"
/
"https://console.cloud.google.com/storage/browser"
}
readonly
timestamp
=
$(
date
+%s
)
readonly
timestamp
=
$(
date
+%s
)
function
upload_version
()
{
#########################################################################
echo
-n
'Run starting at '
;
date
-d
"@
${
timestamp
}
"
# Try to discover the kubernetes version.
# prints version
# Try to discover the kubernetes version.
function
find_version
()
{
local
version
=
""
if
[[
-e
"version"
]]
;
then
if
[[
-e
"version"
]]
;
then
version
=
$(
cat
"version"
)
cat
version
elif
[[
-e
"hack/lib/version.sh"
]]
;
then
elif
[[
-e
"hack/lib/version.sh"
]]
;
then
version
=
$
(
(
export
KUBE_ROOT
=
"."
export
KUBE_ROOT
=
"."
source
"hack/lib/version.sh"
source
"hack/lib/version.sh"
kube::version::get_version_vars
kube::version::get_version_vars
echo
"
${
KUBE_GIT_VERSION
-
}
"
echo
"
${
KUBE_GIT_VERSION
-
}
"
)
)
fi
fi
}
function
upload_version
()
{
local
-r
version
=
$(
find_version
)
local
upload_attempt
echo
-n
'Run starting at '
;
date
-d
"@
${
timestamp
}
"
if
[[
-n
"
${
version
}
"
]]
;
then
if
[[
-n
"
${
version
}
"
]]
;
then
echo
"Found Kubernetes version:
${
version
}
"
echo
"Found Kubernetes version:
${
version
}
"
...
@@ -99,8 +105,52 @@ function upload_version() {
...
@@ -99,8 +105,52 @@ function upload_version() {
done
done
}
}
#########################################################################
# Maintain a single file storing the full build version, Jenkins' job number
# build state. Limit its size so it does not grow unbounded.
# This is primarily used for and by the
# github.com/kubernetes/release/find_green_build tool.
# @param build_result - the state of the build
#
function
update_job_result_cache
()
{
local
-r
build_result
=
$1
local
-r
version
=
$(
find_version
)
local
-r
job_results
=
${
gcs_job_path
}
/jobResultsCache.json
local
-r
tmp_results
=
"
${
WORKSPACE
}
/_tmp/jobResultsCache.tmp"
local
-r
cache_size
=
200
local
upload_attempt
if
[[
-n
"
${
version
}
"
]]
;
then
echo
"Found Kubernetes version:
${
version
}
"
else
echo
"Could not find Kubernetes version"
fi
mkdir
-p
${
tmp_results
%/*
}
for
upload_attempt
in
$(
seq
3
)
;
do
echo
"Copying
${
job_results
}
to
${
tmp_results
}
(attempt
${
upload_attempt
}
)"
gsutil
-q
cp
${
job_results
}
${
tmp_results
}
2>&-
||
continue
break
done
echo
"{
\"
version
\"
:
\"
${
version
}
\"
,
\"
buildnumber
\"
:
\"
${
BUILD_NUMBER
}
\"
,"
\
"
\"
result
\"
:
\"
${
build_result
}
\"
}"
>>
${
tmp_results
}
for
upload_attempt
in
$(
seq
3
)
;
do
echo
"Copying
${
tmp_results
}
to
${
job_results
}
(attempt
${
upload_attempt
}
)"
gsutil
-q
-h
"Content-Type:application/json"
cp
-a
"
${
gcs_acl
}
"
\
<
(
tail
-
${
cache_size
}
${
tmp_results
}
)
${
job_results
}
||
continue
break
done
rm
-f
${
tmp_results
}
}
function
upload_artifacts_and_build_result
()
{
function
upload_artifacts_and_build_result
()
{
local
-r
build_result
=
$1
local
-r
build_result
=
$1
local
upload_attempt
echo
-n
'Run finished at '
;
date
-d
"@
${
timestamp
}
"
echo
-n
'Run finished at '
;
date
-d
"@
${
timestamp
}
"
for
upload_attempt
in
$(
seq
3
)
;
do
for
upload_attempt
in
$(
seq
3
)
;
do
...
@@ -150,6 +200,7 @@ if [[ -n "${JENKINS_BUILD_STARTED:-}" ]]; then
...
@@ -150,6 +200,7 @@ if [[ -n "${JENKINS_BUILD_STARTED:-}" ]]; then
upload_version
upload_version
elif
[[
-n
"
${
JENKINS_BUILD_FINISHED
:-}
"
]]
;
then
elif
[[
-n
"
${
JENKINS_BUILD_FINISHED
:-}
"
]]
;
then
upload_artifacts_and_build_result
${
JENKINS_BUILD_FINISHED
}
upload_artifacts_and_build_result
${
JENKINS_BUILD_FINISHED
}
update_job_result_cache
${
JENKINS_BUILD_FINISHED
}
else
else
echo
"Called without JENKINS_BUILD_STARTED or JENKINS_BUILD_FINISHED set."
echo
"Called without JENKINS_BUILD_STARTED or JENKINS_BUILD_FINISHED set."
echo
"Assuming a legacy invocation."
echo
"Assuming a legacy invocation."
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment