Bug 1408879

Summary: OPENSHIFT_BUILD_COMMIT env is not set on manual builds
Product: OpenShift Container Platform Reporter: Eric Rich <erich>
Component: BuildAssignee: Ben Parees <bparees>
Status: CLOSED ERRATA QA Contact: Wang Haoran <haowang>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.3.1CC: aos-bugs, dlbewley, dyan, tdawson, wzheng
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: Different code paths for retrieving and setting the commit information. Consequence: OPENSHIFT_BUILD_COMMIT env variable is only set in the output image when the build is triggered by a webhook. Fix: Use a common code path for retrieving and setting the commit information so it is always available to be added to the image. Result: OPENSHIFT_BUILD_COMMIT env variable is always present in the output image.
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-04-12 19:08:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Rich 2016-12-27 22:51:18 UTC
Description of problem:

https://github.com/openshift/origin/issues/6817


Version-Release number of selected component (if applicable): 3.3.0


How reproducible: 100% 


Steps to Reproduce: see https://github.com/openshift/origin/issues/6817

Actual results: 
OPENSHIFT_BUILD_COMMIT env var not set when build is triggered

Expected results:

OPENSHIFT_BUILD_COMMIT env is set when build is triggered 


Additional info:

Comment 1 Cesar Wong 2017-01-03 15:23:47 UTC
Ben assigning to you, since you are assigned the origin issue

Comment 2 Ben Parees 2017-01-03 16:23:18 UTC
we should be adding the commit information in a consistent way:

    clone the git repo
    check out the requested commit/ref (if any, otherwise master)
    check what the current commit information is
    apply that commit information as labels/env/etc.

i'm guessing this is currently broken because the ENV comes from the webhook info and the label comes from the flow I just described.

Comment 3 Ben Parees 2017-01-04 21:55:27 UTC
https://github.com/openshift/origin/pull/12390

Comment 4 Dongbo Yan 2017-01-09 07:42:44 UTC
Verified 

openshift v1.5.0-alpha.1+15872c0-61
kubernetes v1.4.0+776c994
etcd 3.1.0-rc.0
devenv-centos7_5644 (ami-8fc12599)

docker build logs:
Step 13 : ENV "OPENSHIFT_BUILD_NAME" "ruby-sample-build-1" "OPENSHIFT_BUILD_NAMESPACE" "dyan" "OPENSHIFT_BUILD_SOURCE" "git://github.com/openshift/ruby-hello-world.git" "OPENSHIFT_BUILD_COMMIT" "e79d8870be808a7abb4ab304e94c8bee69d909c6"
 ---> Running in a674847812b0
 ---> a6fed1ff2c15
Removing intermediate container a674847812b0

docker build and sti build image
$ env |grep OPENSHIFT
OPENSHIFT_BUILD_COMMIT=e79d8870be808a7abb4ab304e94c8bee69d909c6
OPENSHIFT_BUILD_NAME=ruby-sample-build-1
OPENSHIFT_BUILD_SOURCE=https://github.com/openshift/ruby-hello-world.git
OPENSHIFT_BUILD_NAMESPACE=dyan1

need verify on ocp once pr merged

Comment 5 Troy Dawson 2017-01-20 23:05:39 UTC
This has been merged into ocp and is in OCP v3.5.0.7 or newer.

Comment 6 Dongbo Yan 2017-01-22 06:12:02 UTC
Verified

openshift v3.5.0.7+390ef18
kubernetes v1.5.2+43a9be4
etcd 3.1.0-rc.0

Comment 8 errata-xmlrpc 2017-04-12 19:08:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2017:0884