From f3d162dc17b4b410031a1896f6f9abe967e0f143 Mon Sep 17 00:00:00 2001
From: Michal Kovarik <mkovarik@redhat.com>
Date: Feb 24 2020 12:40:38 +0000
Subject: [PATCH 1/5] C3I: Reduce number of files, define template in env


---

diff --git a/openshift/pipelines/Makefile b/openshift/pipelines/Makefile
index beb43ad..93127ca 100644
--- a/openshift/pipelines/Makefile
+++ b/openshift/pipelines/Makefile
@@ -21,14 +21,14 @@ help:
 install:
 	@for job in $(JOBS); do \
 		echo "[PIPELINE] Updating pipeline job \"$${job}\"..." ; \
-	  template_file=$$(cat ./$(JOBS_DIR)/$${job}.tmpl); \
+	  template_file=$$(awk '/^TEMPLATE=/ {split($$0,a,"="); print a[2]}' ./$(JOBS_DIR)/$${job}.env); \
 		jinja2 ./$(TEMPLATES_DIR)/$${template_file} | $(OC_CMD) process --local -f - \
 			--param-file ./$(JOBS_DIR)/$${job}.env | $(OC_CMD) apply -f -; \
 		echo "[PIPELINE] Pipeline job \"$${job}\" updated" ; \
 	done
 uninstall:
 	@for job in $(JOBS); do \
-	  template_file=$$(cat ./$(JOBS_DIR)/$${job}.tmpl); \
+	  template_file=$$(awk '/^TEMPLATE=/ {split($0,a,"="); print a[2]}' ./$(JOBS_DIR)/$${job}.env); \
 		template_name=$${template_file%.y?ml}; \
 		template_name=$${template_name%-template}; \
 		echo "[PIPELINE] Deleting pipeline job \"$${job}\"..." ; \
diff --git a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-prod.env b/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-prod.env
index e81e1d8..9444031 100644
--- a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-prod.env
+++ b/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-prod.env
@@ -1,4 +1,5 @@
 NAME=waiverdb-greenwave-promote-to-prod
+TEMPLATE=waiverdb-greenwave-trigger.yaml
 SOURCE_CONTAINER_REPO=quay.io/factory2/waiverdb
 TARGET_TAG=prod
 DECISION_CONTEXT_REGEX=c3i_promote_stage_to_prod
diff --git a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-prod.tmpl b/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-prod.tmpl
deleted file mode 100644
index aab28b4..0000000
--- a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-prod.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-greenwave-trigger.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-stage.env b/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-stage.env
index 1888ce9..ea3d263 100644
--- a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-stage.env
+++ b/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-stage.env
@@ -1,4 +1,5 @@
 NAME=waiverdb-greenwave-promote-to-stage
+TEMPLATE=waiverdb-greenwave-trigger.yaml
 SOURCE_CONTAINER_REPO=quay.io/factory2/waiverdb
 TARGET_TAG=stage
 DECISION_CONTEXT_REGEX=c3i_promote_dev_to_stage
diff --git a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-stage.tmpl b/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-stage.tmpl
deleted file mode 100644
index aab28b4..0000000
--- a/openshift/pipelines/jobs/waiverdb-greenwave-promote-to-stage.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-greenwave-trigger.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-polling-for-master.env b/openshift/pipelines/jobs/waiverdb-polling-for-master.env
index 77db732..13507ef 100644
--- a/openshift/pipelines/jobs/waiverdb-polling-for-master.env
+++ b/openshift/pipelines/jobs/waiverdb-polling-for-master.env
@@ -1,3 +1,4 @@
 NAME=waiverdb-polling-for-master
+TEMPLATE=waiverdb-polling-pagure.yaml
 PAGURE_POLLING_SCHEDULE="H/5 * * * *"
 PAGURE_POLLED_BRANCH=master
diff --git a/openshift/pipelines/jobs/waiverdb-polling-for-master.tmpl b/openshift/pipelines/jobs/waiverdb-polling-for-master.tmpl
deleted file mode 100644
index 3d4e8e5..0000000
--- a/openshift/pipelines/jobs/waiverdb-polling-for-master.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-polling-pagure.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-polling-for-prs.env b/openshift/pipelines/jobs/waiverdb-polling-for-prs.env
index 907d8d3..fc15b8a 100644
--- a/openshift/pipelines/jobs/waiverdb-polling-for-prs.env
+++ b/openshift/pipelines/jobs/waiverdb-polling-for-prs.env
@@ -1,3 +1,4 @@
 NAME=waiverdb-polling-for-prs
+TEMPLATE=waiverdb-polling-pagure.yaml
 PAGURE_POLLING_FOR_PR=true
 PAGURE_POLLING_SCHEDULE="H/5 * * * *"
diff --git a/openshift/pipelines/jobs/waiverdb-polling-for-prs.tmpl b/openshift/pipelines/jobs/waiverdb-polling-for-prs.tmpl
deleted file mode 100644
index 3d4e8e5..0000000
--- a/openshift/pipelines/jobs/waiverdb-polling-for-prs.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-polling-pagure.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-postmerge.env b/openshift/pipelines/jobs/waiverdb-postmerge.env
index 320dbfe..52a6bc4 100644
--- a/openshift/pipelines/jobs/waiverdb-postmerge.env
+++ b/openshift/pipelines/jobs/waiverdb-postmerge.env
@@ -1,3 +1,4 @@
 NAME=waiverdb-postmerge
+TEMPLATE=waiverdb-build-template.yaml
 PAGURE_DOC_REPO_NAME= # Temporarily disable doc push to workaround https://pagure.io/pagure/issue/3919. Remove this line when it is fixed.
 MAIL_ADDRESS=pnt-factory2-devel@redhat.com 
diff --git a/openshift/pipelines/jobs/waiverdb-postmerge.tmpl b/openshift/pipelines/jobs/waiverdb-postmerge.tmpl
deleted file mode 100644
index 316b89d..0000000
--- a/openshift/pipelines/jobs/waiverdb-postmerge.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-build-template.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-premerge.env b/openshift/pipelines/jobs/waiverdb-premerge.env
index 9c43e62..26f75e4 100644
--- a/openshift/pipelines/jobs/waiverdb-premerge.env
+++ b/openshift/pipelines/jobs/waiverdb-premerge.env
@@ -1 +1,2 @@
 NAME=waiverdb-premerge
+TEMPLATE=waiverdb-build-template.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-premerge.tmpl b/openshift/pipelines/jobs/waiverdb-premerge.tmpl
deleted file mode 100644
index 316b89d..0000000
--- a/openshift/pipelines/jobs/waiverdb-premerge.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-build-template.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-trigger-on-latest-tag.env b/openshift/pipelines/jobs/waiverdb-trigger-on-latest-tag.env
index 65f4624..16ba86e 100644
--- a/openshift/pipelines/jobs/waiverdb-trigger-on-latest-tag.env
+++ b/openshift/pipelines/jobs/waiverdb-trigger-on-latest-tag.env
@@ -1,4 +1,5 @@
 NAME=waiverdb-trigger-on-latest-tag
+TEMPLATE=waiverdb-repotracker-trigger.yaml
 MESSAGING_TOPIC=Consumer.rh-jenkins-ci-plugin.c3i-waiverdb-trigger-on-latest-tag.VirtualTopic.eng.repotracker.container.tag.>
 ENVIRONMENT=stage
 TRACKED_TAG=latest
diff --git a/openshift/pipelines/jobs/waiverdb-trigger-on-latest-tag.tmpl b/openshift/pipelines/jobs/waiverdb-trigger-on-latest-tag.tmpl
deleted file mode 100644
index 9637c92..0000000
--- a/openshift/pipelines/jobs/waiverdb-trigger-on-latest-tag.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-repotracker-trigger.yaml
diff --git a/openshift/pipelines/jobs/waiverdb-trigger-on-stage-tag.env b/openshift/pipelines/jobs/waiverdb-trigger-on-stage-tag.env
index 48b2d71..73762c3 100644
--- a/openshift/pipelines/jobs/waiverdb-trigger-on-stage-tag.env
+++ b/openshift/pipelines/jobs/waiverdb-trigger-on-stage-tag.env
@@ -1,4 +1,5 @@
 NAME=waiverdb-trigger-on-stage-tag
+TEMPLATE=waiverdb-repotracker-trigger.yaml
 MESSAGING_TOPIC=Consumer.rh-jenkins-ci-plugin.c3i-waiverdb-trigger-on-stage-tag.VirtualTopic.eng.repotracker.container.tag.>
 TRACKED_TAG=stage
 ENVIRONMENT=prod
diff --git a/openshift/pipelines/jobs/waiverdb-trigger-on-stage-tag.tmpl b/openshift/pipelines/jobs/waiverdb-trigger-on-stage-tag.tmpl
deleted file mode 100644
index 9637c92..0000000
--- a/openshift/pipelines/jobs/waiverdb-trigger-on-stage-tag.tmpl
+++ /dev/null
@@ -1 +0,0 @@
-waiverdb-repotracker-trigger.yaml
diff --git a/openshift/pipelines/templates/waiverdb-build-template.yaml b/openshift/pipelines/templates/waiverdb-build-template.yaml
index ca7de7c..b6eaa68 100644
--- a/openshift/pipelines/templates/waiverdb-build-template.yaml
+++ b/openshift/pipelines/templates/waiverdb-build-template.yaml
@@ -31,6 +31,8 @@ parameters:
   description: This field is used to deploy multiple pipelines to one OpenShift project from this template.
   required: true
   value: waiverdb-build
+- name: TEMPLATE
+  description: Placeholder for template generation, not used.
 - name: WAIVERDB_GIT_REPO
   displayName: WaiverDB Git repo URL
   description: Default WaiverDB Git repo URL in which to run dev tests against
diff --git a/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml b/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml
index f6d0fed..90c698e 100644
--- a/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml
+++ b/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml
@@ -12,6 +12,8 @@ parameters:
   displayName: Short unique identifier for the templated instances
   description: This field is used to deploy multiple pipelines to one OpenShift project from this template.
   value: waiverdb-greenwave-trigger
+- name: TEMPLATE
+  description: Placeholder for template generation, not used.
 - name: DECISION_CONTEXT_REGEX
   displayName: Regex pattern for Greenwave decision context in CI message
   required: true
diff --git a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml
index 194abf3..5f48804 100644
--- a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml
+++ b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml
@@ -13,6 +13,8 @@ parameters:
   description: This field is used to deploy multiple pipelines to one OpenShift project from this template.
   required: true
   value: waiverdb-polling-to-pagure
+- name: TEMPLATE
+  description: Placeholder for template generation, not used.
 - name: PAGURE_REPO_NAME
   displayName: Pagure project name
   description: <username>/<namespace>/<repo>
diff --git a/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml b/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml
index 307c62c..fa73dbe 100644
--- a/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml
+++ b/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml
@@ -12,6 +12,8 @@ parameters:
   displayName: Short unique identifier for the templated instances
   description: This field is used to deploy multiple pipelines to one OpenShift project from this template.
   value: waiverdb-repotracker-trigger
+- name: TEMPLATE
+  description: Placeholder for template generation, not used.
 - name: TRACKED_CONTAINER_REPO
   displayName: Container repo to be tracked
   value: "quay.io/factory2/waiverdb"

From 9cb7dfc709aaa7f8c0a93501bc6503b1c9eaeabf Mon Sep 17 00:00:00 2001
From: Michal Kovarik <mkovarik@redhat.com>
Date: Feb 24 2020 12:40:45 +0000
Subject: [PATCH 2/5] C3I: remove dependency on NSS_WRAPPER


---

diff --git a/openshift/containers/jenkins-slave/Dockerfile b/openshift/containers/jenkins-slave/Dockerfile
index 0c103e2..2e8aeaf 100644
--- a/openshift/containers/jenkins-slave/Dockerfile
+++ b/openshift/containers/jenkins-slave/Dockerfile
@@ -20,7 +20,7 @@ ARG CA_URLS=""
 USER root
 
 RUN ${DNF_CMD} install -y \
-    java-1.8.0-openjdk-headless gettext nss_wrapper git-core \
+    java-1.8.0-openjdk-headless gettext git-core \
     tar gzip skopeo wget make bind-utils \
     origin-clients \
     # Jenkins pipeline 'sh' steps seem to require ps
diff --git a/openshift/containers/jenkins-slave/jenkins-agent b/openshift/containers/jenkins-slave/jenkins-agent
index 550e3a4..8614036 100644
--- a/openshift/containers/jenkins-slave/jenkins-agent
+++ b/openshift/containers/jenkins-slave/jenkins-agent
@@ -39,13 +39,10 @@
 
 # Dynamically create a passwd file for non-arbitrary UIDs.
 # Taken from: https://docs.openshift.org/latest/creating_images/guidelines.html#openshift-origin-specific-guidelines
-export USER_ID=$(id -u)
-export GROUP_ID=$(id -g)
-
-# Skip for root user
-if [ x"$USER_ID" != x"0" ]; then
-    cp /etc/passwd $NSS_WRAPPER_PASSWD
-    echo "jenkins:x:${USER_ID}:${GROUP_ID}:jenkins:${HOME}:/bin/bash" >> $NSS_WRAPPER_PASSWD
+if ! whoami &> /dev/null; then
+  if [ -w /etc/passwd ]; then
+    echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
+  fi
 fi
 
 if [ $# -eq 1 ]; then
diff --git a/openshift/pipelines/templates/waiverdb-build.Jenkinsfile b/openshift/pipelines/templates/waiverdb-build.Jenkinsfile
index 6005d5a..eaa7f5f 100644
--- a/openshift/pipelines/templates/waiverdb-build.Jenkinsfile
+++ b/openshift/pipelines/templates/waiverdb-build.Jenkinsfile
@@ -22,13 +22,8 @@ pipeline {
           imagePullPolicy: Always
           tty: true
           env:
-          # Required by unit tests: Set up NSS Wrapper to generate a fake user name for the random UID assigned by OpenShift
-          - name: LD_PRELOAD
-            value: '/usr/lib64/libnss_wrapper.so'
-          - name: NSS_WRAPPER_PASSWD
-            value: '/tmp/passwd'
-          - name: NSS_WRAPPER_GROUP
-            value: '/etc/group'
+          - name: USER_NAME
+            value: jenkins
           volumeMounts:
           - name: postgresql-socket
             mountPath: /var/run/postgresql

From a069f1831f5fb58fcc94553ffc4d4e9644ad79ae Mon Sep 17 00:00:00 2001
From: Michal Kovarik <mkovarik@redhat.com>
Date: Feb 24 2020 12:40:45 +0000
Subject: [PATCH 3/5] C3I: separate pagure configuration


Moving pagure configuration to one place to improve c3i testing.

---

diff --git a/openshift/pipelines/templates/snippets/waiverdb-pagure-parameters.yaml b/openshift/pipelines/templates/snippets/waiverdb-pagure-parameters.yaml
new file mode 100644
index 0000000..1f1c303
--- /dev/null
+++ b/openshift/pipelines/templates/snippets/waiverdb-pagure-parameters.yaml
@@ -0,0 +1,31 @@
+- name: PAGURE_REPO_NAME
+  displayName: Pagure project name
+  description: <username>/<namespace>/<repo>
+  required: true
+  value: waiverdb
+- name: PAGURE_REPO_IS_FORK
+  displayName: Is the Pagure repo a fork?
+  required: true
+  value: "false"
+- name: WAIVERDB_GIT_REPO
+  displayName: WaiverDB Git repo URL
+  description: Default WaiverDB Git repo URL in which to run dev tests against
+  required: true
+  value: "https://pagure.io/waiverdb.git"
+- name: PAGURE_DOC_REPO_NAME
+  displayName: namespace/project of Pagure doc repo for publishing docs
+  description: If not emptry, docs will be published to the specified Pagure doc repo when this is a post-merge build
+  required: false
+  value: waiverdb
+- name: PAGURE_DOC_SECRET
+  displayName: Name of the OpenShift SSH secret for publishing docs to Pagure.
+  required: false
+  value: pagure-doc-secret
+- name: PAGURE_URL
+  displayName: Pagure URL
+  value: https://pagure.io
+- name: PAGURE_REPO_NAME
+  value: waiverdb
+- name: PAGURE_API_KEY_SECRET_NAME
+  displayName: Name of Pagure API key secret for updating Pagure pull-request statuses
+  value: 'pagure-api-key'
diff --git a/openshift/pipelines/templates/waiverdb-build-template.yaml b/openshift/pipelines/templates/waiverdb-build-template.yaml
index b6eaa68..8c334b9 100644
--- a/openshift/pipelines/templates/waiverdb-build-template.yaml
+++ b/openshift/pipelines/templates/waiverdb-build-template.yaml
@@ -33,11 +33,6 @@ parameters:
   value: waiverdb-build
 - name: TEMPLATE
   description: Placeholder for template generation, not used.
-- name: WAIVERDB_GIT_REPO
-  displayName: WaiverDB Git repo URL
-  description: Default WaiverDB Git repo URL in which to run dev tests against
-  required: true
-  value: "https://pagure.io/waiverdb.git"
 - name: WAIVERDB_GIT_REF
   displayName: WaiverDB Git repo ref
   description: Default WaiverDB Git repo ref in which to run dev tests against
@@ -56,15 +51,6 @@ parameters:
   displayName: Container image for Jenkins slave pods
   required: true
   value: docker-registry.upshift.redhat.com/factory2/waiverdb-jenkins-slave:latest
-- name: PAGURE_DOC_REPO_NAME
-  displayName: namespace/project of Pagure doc repo for publishing docs
-  description: If not emptry, docs will be published to the specified Pagure doc repo when this is a post-merge build
-  required: false
-  value: waiverdb
-- name: PAGURE_DOC_SECRET
-  displayName: Name of the OpenShift SSH secret for publishing docs to Pagure.
-  required: false
-  value: pagure-doc-secret
 - name: WAIVERDB_DEV_IMAGE_DESTINATIONS
   displayName: Comma seperated list of container repositories (without tag) to which the built WaiverDB dev image will be pushed
   description: OpenShift registries must be prefixed with 'atomic:'
@@ -107,18 +93,9 @@ parameters:
 - name: MESSAGING_PROVIDER
   displayName: Name of the JMS messaging provider
   value: Red Hat UMB
-- name: PAGURE_URL
-  displayName: Pagure URL
-  value: https://pagure.io
-- name: PAGURE_REPO_NAME
-  value: waiverdb
-- name: PAGURE_REPO_IS_FORK
-  value: 'false'
-- name: PAGURE_API_KEY_SECRET_NAME
-  displayName: Name of Pagure API key secret for updating Pagure pull-request statuses
-  value: 'pagure-api-key'
 - name: MAIL_ADDRESS
   displayName: If set, build failure messages to this mail address.
+{% include "snippets/waiverdb-pagure-parameters.yaml" %}
 {% include "snippets/c3i-library-parameters.yaml" %}
 labels:
   template: waiverdb-build
diff --git a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml
index 5f48804..0c2ab04 100644
--- a/openshift/pipelines/templates/waiverdb-polling-pagure.yaml
+++ b/openshift/pipelines/templates/waiverdb-polling-pagure.yaml
@@ -15,22 +15,10 @@ parameters:
   value: waiverdb-polling-to-pagure
 - name: TEMPLATE
   description: Placeholder for template generation, not used.
-- name: PAGURE_REPO_NAME
-  displayName: Pagure project name
-  description: <username>/<namespace>/<repo>
-  required: true
-  value: waiverdb
-- name: PAGURE_REPO_IS_FORK
-  displayName: Is the Pagure repo a fork?
-  required: true
-  value: "false"
 - name: PAGURE_POLLING_FOR_PR
   displayName: set to 'true' to poll for PRs, or 'false' for the master branch
   required: true
   value: "false"
-- name: PAGURE_URL
-  displayName: Pagure URL
-  value: "https://pagure.io"
 - name: PAGURE_POLLING_SCHEDULE
   displayName: Schedule of polling
   description: using cron-style syntax
@@ -60,6 +48,7 @@ parameters:
   displayName: Name of OpenShift cloud in Jenkins master configuration
   required: true
   value: openshift
+{% include "snippets/waiverdb-pagure-parameters.yaml" %}
 {% include "snippets/c3i-library-parameters.yaml" %}
 objects:
 - kind: ServiceAccount

From 649e446b30499aefee0bb499e82459d23af9750e Mon Sep 17 00:00:00 2001
From: Michal Kovarik <mkovarik@redhat.com>
Date: Feb 24 2020 12:40:45 +0000
Subject: [PATCH 4/5] C3I: allow to trigger test/promotion without CI msg


---

diff --git a/openshift/pipelines/templates/waiverdb-greenwave-trigger.Jenkinsfile b/openshift/pipelines/templates/waiverdb-greenwave-trigger.Jenkinsfile
index d8a758a..1eb2e6b 100644
--- a/openshift/pipelines/templates/waiverdb-greenwave-trigger.Jenkinsfile
+++ b/openshift/pipelines/templates/waiverdb-greenwave-trigger.Jenkinsfile
@@ -32,17 +32,18 @@ pipeline {
     stage("Message Check and setup") {
       steps {
         script {
-          if (!params.CI_MESSAGE) {
+          if (params.CI_MESSAGE) {
+            def message = readJSON text: params.CI_MESSAGE
+            // Extract the digest of the image to be promoted.
+            // e.g. factory2/waiverdb@sha256:35201c572fc8a137862b7a256476add8d7465fa5043d53d117f4132402f8ef6b
+            //   -> sha256:35201c572fc8a137862b7a256476add8d7465fa5043d53d117f4132402f8ef6b
+            def digest = (message.msg.subject_identifier =~ /@(sha256:\w+)$/)[0][1]
+            // Generate the pull spec of the image
+            // e.g. quay.io/factory2/waiverdb@sha256:35201c572fc8a137862b7a256476add8d7465fa5043d53d117f4132402f8ef6b
+            env.IMAGE = "${params.SOURCE_CONTAINER_REPO}@${digest}"
+          } else if (!params.IMAGE) {
             error("This build is not started by a CI message. Only configurations were done.")
           }
-          def message = readJSON text: params.CI_MESSAGE
-          // Extract the digest of the image to be promoted.
-          // e.g. factory2/waiverdb@sha256:35201c572fc8a137862b7a256476add8d7465fa5043d53d117f4132402f8ef6b
-          //   -> sha256:35201c572fc8a137862b7a256476add8d7465fa5043d53d117f4132402f8ef6b
-          def digest = (message.msg.subject_identifier =~ /@(sha256:\w+)$/)[0][1]
-          // Generate the pull spec of the image
-          // e.g. quay.io/factory2/waiverdb@sha256:35201c572fc8a137862b7a256476add8d7465fa5043d53d117f4132402f8ef6b
-          env.IMAGE = "${params.SOURCE_CONTAINER_REPO}@${digest}"
           echo "Starting promotion of image ${env.IMAGE} to :${params.TARGET_TAG}..."
           // Setting up registry credentials
           dir ("${env.HOME}/.docker") {
diff --git a/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml b/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml
index 90c698e..42073f0 100644
--- a/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml
+++ b/openshift/pipelines/templates/waiverdb-greenwave-trigger.yaml
@@ -12,6 +12,8 @@ parameters:
   displayName: Short unique identifier for the templated instances
   description: This field is used to deploy multiple pipelines to one OpenShift project from this template.
   value: waiverdb-greenwave-trigger
+- name: IMAGE
+  displayName: Manual promotion of IMAGE, expects $REPO/$IMAGE:[$TAG|@sha:$DIGEST]
 - name: TEMPLATE
   description: Placeholder for template generation, not used.
 - name: DECISION_CONTEXT_REGEX
@@ -94,6 +96,8 @@ objects:
         env:
         - name: OPENSHIFT_CLOUD_NAME
           value: "${OPENSHIFT_CLOUD_NAME}"
+        - name: IMAGE
+          value: "$IMAGE"
         - name: PROMOTING_DESTINATIONS
           value: "${PROMOTING_DESTINATIONS}"
         - name: CONTAINER_REGISTRY_CREDENTIALS
diff --git a/openshift/pipelines/templates/waiverdb-repotracker-trigger.Jenkinsfile b/openshift/pipelines/templates/waiverdb-repotracker-trigger.Jenkinsfile
index 942a57f..b71a946 100644
--- a/openshift/pipelines/templates/waiverdb-repotracker-trigger.Jenkinsfile
+++ b/openshift/pipelines/templates/waiverdb-repotracker-trigger.Jenkinsfile
@@ -3,7 +3,7 @@ pipeline {
   {% include "snippets/default-agent.groovy" %}
   options {
     timestamps()
-    timeout(time: 120, unit: 'MINUTES')
+    timeout(time: 60, unit: 'MINUTES')
     buildDiscarder(logRotator(numToKeepStr: '10'))
   }
   triggers {
@@ -22,15 +22,18 @@ pipeline {
     stage("Message Check and setup") {
       steps {
         script {
-          if (!params.CI_MESSAGE) {
+          if (params.CI_MESSAGE) {
+            def message = readJSON text: params.CI_MESSAGE
+            echo "Tag :${message.tag} is ${message.action} in ${message.repo}. New digest: ${message.digest}"
+            env.IMAGE = "${message.repo}@${message.digest}"
+            env.PIPELINE_ID = "c3i-waiverdb-tag-${params.TRACKED_TAG}-${message.digest[-9..-1]}"
+          } else if (params.IMAGE) {
+            env.PIPELINE_ID = "c3i-waiverdb-tag-${params.TRACKED_TAG}-manual-${UUID.randomUUID().toString().substring(0, 4)}"
+          } else {
             error("This build is not started by a CI message. Only configurations were done.")
           }
-          def message = readJSON text: params.CI_MESSAGE
-          echo "Tag :${message.tag} is ${message.action} in ${message.repo}. New digest: ${message.digest}"
-          env.IMAGE = "${message.repo}@${message.digest}"
-          echo "Triggering a job to test if ${env.IMAGE} meets all criteria of desired tag :${message.tag}"
+          echo "Triggering a job to test if ${env.IMAGE} meets all criteria of desired tag :${params.TRACKED_TAG}"
           env.IMAGE_IS_SCRATCH = false
-          env.PIPELINE_ID = "c3i-waiverdb-tag-${message.tag}-${message.digest[-9..-1]}"
         }
       }
     }
diff --git a/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml b/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml
index fa73dbe..ceec30e 100644
--- a/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml
+++ b/openshift/pipelines/templates/waiverdb-repotracker-trigger.yaml
@@ -17,6 +17,8 @@ parameters:
 - name: TRACKED_CONTAINER_REPO
   displayName: Container repo to be tracked
   value: "quay.io/factory2/waiverdb"
+- name: IMAGE
+  displayName: Manual trigger tests of IMAGE, expects $REPO/$IMAGE:[$TAG|@sha:$DIGEST]
 - name: TRACKED_TAG
   displayName: Name of tag to be tracked
   required: true
@@ -91,7 +93,9 @@ objects:
         - name: "OPENSHIFT_CLOUD_NAME"
           value: "${OPENSHIFT_CLOUD_NAME}"
         - name: "JENKINS_AGENT_IMAGE"
-          value:  "${JENKINS_AGENT_IMAGE}"
+          value: "${JENKINS_AGENT_IMAGE}"
+        - name: "IMAGE"
+          value: "${IMAGE}"
         - name: "JENKINS_AGENT_SERVICE_ACCOUNT"
           value: "${NAME}-jenkins-slave"
         - name: "TRACKED_CONTAINER_REPO"

From aa6eebcdfb832efc346c419571311d0f41dfba37 Mon Sep 17 00:00:00 2001
From: Michal Kovarik <mkovarik@redhat.com>
Date: Feb 24 2020 12:40:45 +0000
Subject: [PATCH 5/5] C3I: fix koji service name


---

diff --git a/openshift/pipelines/templates/snippets/waiverdb-full-integration-test.groovy b/openshift/pipelines/templates/snippets/waiverdb-full-integration-test.groovy
index f265524..84006a5 100644
--- a/openshift/pipelines/templates/snippets/waiverdb-full-integration-test.groovy
+++ b/openshift/pipelines/templates/snippets/waiverdb-full-integration-test.groovy
@@ -26,7 +26,7 @@ stage('Run integration tests') {
                 '-e', "WAIVERDB_IMAGE=${env.IMAGE}",
                 '-e', "PIPELINE_ID=${env.PIPELINE_ID}",
                 '-e', "PAAS_DOMAIN=${env.PAAS_DOMAIN}",
-                '-e', "SERVICES_TO_DEPLOY='resultsdb-updater datanommer greenwave resultsdb umb waiverdb datagrepper krb5 ldap koji'",
+                '-e', "SERVICES_TO_DEPLOY='resultsdb-updater datanommer greenwave resultsdb umb waiverdb datagrepper krb5 ldap koji-hub'",
                 '-e', "TRIGGERED_BY=${env.BUILD_URL}"
               )
             }

