diff --git a/config/controller.yaml b/config/controller.yaml index 6a3f8ba55fb..bcf7e9a8cc4 100644 --- a/config/controller.yaml +++ b/config/controller.yaml @@ -28,6 +28,8 @@ spec: metadata: annotations: cluster-autoscaler.kubernetes.io/safe-to-evict: "false" + # tekton.dev/release value replaced with inputs.params.versionTag in pipeline/tekton/publish.yaml + tekton.dev/release: "devel" labels: app: tekton-pipelines-controller app.kubernetes.io/name: tekton-pipelines diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 0455968a9be..4cd49b098d5 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -23,6 +23,7 @@ import ( "github.com/tektoncd/pipeline/pkg/apis/pipeline" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" "github.com/tektoncd/pipeline/pkg/names" + "github.com/tektoncd/pipeline/pkg/version" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" @@ -42,6 +43,9 @@ const ( // These are effectively const, but Go doesn't have such an annotation. var ( + releaseAnnotation = "tekton.dev/release" + releaseAnnotationValue = version.PipelineVersion + groupVersionKind = schema.GroupVersionKind{ Group: v1alpha1.SchemeGroupVersion.Group, Version: v1alpha1.SchemeGroupVersion.Version, @@ -179,6 +183,9 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha mergedPodContainers = append(mergedPodContainers, sc) } + podAnnotations := taskRun.Annotations + podAnnotations[releaseAnnotation] = releaseAnnotationValue + return &corev1.Pod{ ObjectMeta: metav1.ObjectMeta{ // We execute the build's pod in the same namespace as where the build was @@ -193,7 +200,7 @@ func MakePod(images pipeline.Images, taskRun *v1alpha1.TaskRun, taskSpec v1alpha OwnerReferences: []metav1.OwnerReference{ *metav1.NewControllerRef(taskRun, groupVersionKind), }, - Annotations: taskRun.Annotations, + Annotations: podAnnotations, Labels: makeLabels(taskRun), }, Spec: corev1.PodSpec{ diff --git a/pkg/pod/pod_test.go b/pkg/pod/pod_test.go index 78bf091578a..168374c7edf 100644 --- a/pkg/pod/pod_test.go +++ b/pkg/pod/pod_test.go @@ -322,7 +322,9 @@ func TestMakePod(t *testing.T) { Image: "sidecar-image", }}, }, - wantAnnotations: map[string]string{}, + wantAnnotations: map[string]string{ + "tekton.dev/release": "devel", + }, want: &corev1.PodSpec{ RestartPolicy: corev1.RestartPolicyNever, InitContainers: []corev1.Container{placeToolsInit}, diff --git a/pkg/version/version.go b/pkg/version/version.go index 5969a2f03d3..6342b175e8f 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -15,6 +15,6 @@ package version // NOTE: use go build -ldflags "-X github.com/tektoncd/pipeline/pkg/cmd/version.PipelineVersion=$(git describe)" -const devVersion = "dev" +const devVersion = "devel" var PipelineVersion = devVersion diff --git a/tekton/publish.yaml b/tekton/publish.yaml index 771bf8a9632..66c9befd179 100644 --- a/tekton/publish.yaml +++ b/tekton/publish.yaml @@ -139,6 +139,9 @@ spec: ln -s ${TMPDIR}/source.tar.gz ${d}/kodata/ done + # Rewrite "devel" to inputs.params.versionTag + sed -i 's/devel/$(inputs.params.versionTag)/g' /workspace/go/src/github.com/tektoncd/pipeline/config/controller.yaml + # Publish images and create release.yaml ko resolve --preserve-import-paths -t $(inputs.params.versionTag) -f /workspace/go/src/github.com/tektoncd/pipeline/config/ > /workspace/output/bucket/latest/release.yaml volumeMounts: