OPENDEV: Add patchset-created trigger for push upstream jenkins job.
[infra/cicd.git] / jjb / opendev / push-upstream-jobs.sh
index 02337646d468628ac2ae8243f96d8725030b06ea..83c858d9901906946dc2bb7e80e3b86703200d3d 100755 (executable)
@@ -58,8 +58,13 @@ opendev_remote_url="ssh://$username@$opendev_gerrit_base/$opendev_project"
 
 # GERRIT_BRANCH is the _intended_ branch of the commit under review
 # E.g. git push HEAD:refs/for/master => GERRIT_BRANCH='master'
-# GERRIT_TOPIC is the rest of the refspec after GERRIT_BRANCH
-refspec="$commit_hash:refs/for/$GERRIT_BRANCH/$GERRIT_TOPIC"
+# GERRIT_TOPIC is the rest of the refspec after GERRIT_BRANCH when the topic
+# is set for the change.
+if [ -z "${GERRIT_TOPIC:-}" ] ; then
+    refspec="$commit_hash:refs/for/$GERRIT_BRANCH"
+else
+    refspec="$commit_hash:refs/for/$GERRIT_BRANCH/$GERRIT_TOPIC"
+fi
 
 echo >&2 "Pushing to OpenDev"