-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save git commit of builds in started.json in addition to version #988
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,13 +143,14 @@ def checkout(repo, branch, pull): | |
call([git, 'checkout', 'FETCH_HEAD']) | ||
|
||
|
||
def start(gsutil, paths, stamp, node_name, version): | ||
def start(gsutil, paths, stamp, node_name, version, git_commit): | ||
"""Construct and upload started.json.""" | ||
data = { | ||
'timestamp': stamp, | ||
'jenkins-node': node_name, | ||
'node': node_name, | ||
'version': version, | ||
'git-commit': git_commit, | ||
} | ||
gsutil.upload_json(paths.started, data) | ||
|
||
|
@@ -333,29 +334,42 @@ def node(): | |
|
||
|
||
def find_version(): | ||
"""Determine and return the version of the build.""" | ||
version_file = 'version' | ||
if os.path.isfile(version_file): | ||
# e2e tests which download kubernetes use this path: | ||
with open(version_file) as fp: | ||
return fp.read().strip() | ||
|
||
version_script = 'hack/lib/version.sh' | ||
if os.path.isfile(version_script): | ||
cmd = [ | ||
'bash', '-c', ( | ||
"""Determine and return the version and git commit of the build.""" | ||
try: | ||
# First try using kubectl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is going to work for a dockerized test. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, now that I think about this, I think neither the previous version of this nor this kubectl version work correctly for CI, since we haven't extracted the kubernetes tarball by this point. |
||
for loc in ('client/bin', 'platforms/linux/amd64'): | ||
kubectl_bin = os.path.join(loc, 'kubectl') | ||
if os.path.isfile(kubectl_bin): | ||
kubectl_version_output = call([kubectl_bin, 'version', '--client'], output=True) | ||
m = re.match( | ||
'Client Version: version.Info\{.*GitVersion:"(?P<version>[^"]+)".*GitCommit:"(?P<commit>[^"]+)".*\}', | ||
kubectl_version_output) | ||
if m: | ||
return m.group('version'), m.group('commit') | ||
|
||
# If we can't find kubectl, try using the version.sh script | ||
version_script = 'hack/lib/version.sh' | ||
if os.path.isfile(version_script): | ||
cmd = [ | ||
'bash', '-c', ( | ||
""" | ||
set -o errexit | ||
set -o nounset | ||
export KUBE_ROOT=. | ||
source %s | ||
kube::version::get_version_vars | ||
echo $KUBE_GIT_VERSION | ||
echo $KUBE_GIT_COMMIT | ||
""" % version_script) | ||
] | ||
return call(cmd, output=True).strip() | ||
] | ||
version_lines = call(cmd, output=True).splitlines() | ||
if len(version_lines) == 2: | ||
return version_lines[0], version_lines[1] | ||
|
||
except subprocess.CalledProcessError: | ||
pass | ||
|
||
return 'unknown' | ||
return 'unknown', 'unknown' | ||
|
||
|
||
class Paths(object): # pylint: disable=too-many-instance-attributes,too-few-public-methods | ||
|
@@ -579,7 +593,7 @@ def bootstrap(job, repo, branch, pull, root): | |
os.chdir(root) | ||
checkout(repo, branch, pull) | ||
logging.info('Configure environment...') | ||
version = find_version() | ||
version, git_commit = find_version() | ||
setup_magic_environment(job) | ||
setup_credentials() | ||
if pull: | ||
|
@@ -588,7 +602,7 @@ def bootstrap(job, repo, branch, pull, root): | |
paths = ci_paths(job, build) | ||
gsutil = GSUtil() | ||
logging.info('Start %s at %s...', build, version) | ||
start(gsutil, paths, started, node(), version) | ||
start(gsutil, paths, started, node(), version, git_commit) | ||
success = False | ||
try: | ||
cmd = [job_script(job)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we just going to ignore this file now? what was making it before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's written when the tarball is created - https://github.com/kubernetes/kubernetes/blob/master/build-tools/lib/release.sh#L428.
it should be the same as the
GitVersion
inkubectl version
- but since we're parsing that already, it didn't seem like reading another file was necessary anymore.