Skip to content

Commit ffdeb1b

Browse files
author
OpenShift Bot
authored
Merge pull request #11052 from jim-minter/bz1371047
Merged by openshift-bot
2 parents 3f47210 + 0311df5 commit ffdeb1b

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

pkg/build/api/types.go

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const (
1919
BuildCloneAnnotation = "openshift.io/build.clone-of"
2020
// BuildPodNameAnnotation is an annotation whose value is the name of the pod running this build
2121
BuildPodNameAnnotation = "openshift.io/build.pod-name"
22+
// BuildJenkinsStatusJSONAnnotation is an annotation holding the Jenkins status information
23+
BuildJenkinsStatusJSONAnnotation = "openshift.io/jenkins-status-json"
24+
// BuildJenkinsLogURLAnnotation is an annotation holding a link to the Jenkins build console log
25+
BuildJenkinsLogURLAnnotation = "openshift.io/jenkins-log-url"
26+
// BuildJenkinsBuildURIAnnotation is an annotation holding a link to the Jenkins build
27+
BuildJenkinsBuildURIAnnotation = "openshift.io/jenkins-build-uri"
2228
// BuildLabel is the key of a Pod label whose value is the Name of a Build which is run.
2329
// NOTE: The value for this label may not contain the entire Build name because it will be
2430
// truncated to maximum label length.

pkg/build/generator/generator.go

+9
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,15 @@ func generateBuildFromBuild(build *buildapi.Build, buildConfig *buildapi.BuildCo
745745
// builds without a buildconfig don't have build numbers.
746746
delete(newBuild.Annotations, buildapi.BuildNumberAnnotation)
747747
}
748+
749+
// if they exist, Jenkins reporting annotations must be removed when cloning.
750+
delete(newBuild.Annotations, buildapi.BuildJenkinsStatusJSONAnnotation)
751+
delete(newBuild.Annotations, buildapi.BuildJenkinsLogURLAnnotation)
752+
delete(newBuild.Annotations, buildapi.BuildJenkinsBuildURIAnnotation)
753+
754+
// remove the BuildPodNameAnnotation for good measure.
755+
delete(newBuild.Annotations, buildapi.BuildPodNameAnnotation)
756+
748757
return newBuild
749758
}
750759

pkg/build/generator/generator_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,12 @@ func TestGenerateBuildFromBuild(t *testing.T) {
10621062
build := &buildapi.Build{
10631063
ObjectMeta: kapi.ObjectMeta{
10641064
Name: "test-build",
1065+
Annotations: map[string]string{
1066+
buildapi.BuildJenkinsStatusJSONAnnotation: "foo",
1067+
buildapi.BuildJenkinsLogURLAnnotation: "bar",
1068+
buildapi.BuildJenkinsBuildURIAnnotation: "baz",
1069+
buildapi.BuildPodNameAnnotation: "ruby-sample-build-1-build",
1070+
},
10651071
},
10661072
Spec: buildapi.BuildSpec{
10671073
CommonSpec: buildapi.CommonSpec{
@@ -1084,6 +1090,18 @@ func TestGenerateBuildFromBuild(t *testing.T) {
10841090
if !reflect.DeepEqual(build.ObjectMeta.Labels, newBuild.ObjectMeta.Labels) {
10851091
t.Errorf("Build labels does not match the original Build labels")
10861092
}
1093+
if _, ok := newBuild.ObjectMeta.Annotations[buildapi.BuildJenkinsStatusJSONAnnotation]; ok {
1094+
t.Errorf("%s annotation exists, expected it not to", buildapi.BuildJenkinsStatusJSONAnnotation)
1095+
}
1096+
if _, ok := newBuild.ObjectMeta.Annotations[buildapi.BuildJenkinsLogURLAnnotation]; ok {
1097+
t.Errorf("%s annotation exists, expected it not to", buildapi.BuildJenkinsLogURLAnnotation)
1098+
}
1099+
if _, ok := newBuild.ObjectMeta.Annotations[buildapi.BuildJenkinsBuildURIAnnotation]; ok {
1100+
t.Errorf("%s annotation exists, expected it not to", buildapi.BuildJenkinsBuildURIAnnotation)
1101+
}
1102+
if _, ok := newBuild.ObjectMeta.Annotations[buildapi.BuildPodNameAnnotation]; ok {
1103+
t.Errorf("%s annotation exists, expected it not to", buildapi.BuildPodNameAnnotation)
1104+
}
10871105
}
10881106

10891107
func TestGenerateBuildFromBuildWithBuildConfig(t *testing.T) {

0 commit comments

Comments
 (0)