---

# -----------------------------------------------------------------------
# Copyright 2019-2024 Open Networking Foundation Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------
# SPDX-FileCopyrightText: 2019-2024 Open Networking Foundation Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
# Intent: Generic docker image building + dockerhub publishing tasks
# -----------------------------------------------------------------------

- job-template:
    id: docker-publish
    name: 'docker-publish_{project}'
    description: >+
      Created by {id} job-template from ci-management/jjb/docker-publish.yaml,
      script pipeline/docker-publish.groovy

    triggers:
      - cord-infra-gerrit-trigger-merge:
          gerrit-server-name: '{gerrit-server-name}'
          project-regexp: '^{project}$'
          branch-regexp: '{all-branches-regexp}'
          file-include-regexp: '{all-files-regexp}'
          dependency-jobs: '{dependency-jobs}'

    properties:
      - cord-infra-properties:
          build-days-to-keep: '{build-days-to-keep}'
          artifact-num-to-keep: '{artifact-num-to-keep}'

    wrappers:
      - lf-infra-wrappers:
          build-timeout: '{build-timeout}'
          jenkins-ssh-credential: '{jenkins-ssh-credential}'

    parameters:
      - string:
          name: buildNode
          default: 'ubuntu18.04-basebuild-1c-2g'
          description: 'Name of the Jenkins build executor to run the job on'

      - string:
          name: gitUrl
          default: '{gerrit-server-url}/{project}'
          description: 'URL to the git repo'

      - string:
          name: gitRef
          default: '$GERRIT_PATCHSET_REVISION'
          description: 'git ref to build (commit hash or tag)'

      - string:
          name: projectName
          default: '$GERRIT_PROJECT'
          description: 'Name of the project in Gerrit'

      - string:
          name: branchName
          default: '$GERRIT_BRANCH'
          description: 'Branch of the project in Gerrit'

      - string:
          name: dockerRepo
          default: '{docker-repo}'
          description: >
            "Docker repository to push to ('opencord', 'xosproject', etc.)"

      - string:
          name: dockerRegistry
          default: '{docker-registry}'
          description: "Docker registry to push to (blank for DockerHub)"

      # AWS CPU arch names: `x86_64` `arm64`
      # (which don't align to vendor names... *sigh*)
      - string:
          name: dockerArchList
          default: 'x86_64'
          description: >
            "List of architectures to build containers on, pipe separated
            (nonfunctional currently)"

      - string:
          name: maintainers
          default: '{maintainers}'
          description: "The person that should be notified if this job fails"

      - string:
          name: extraEnvironmentVars
          default: '{extraEnvironmentVars}'
          description: "Provide extra environment variables to the build"

    project-type: pipeline
    concurrent: true
    extraEnvironmentVars: ""

    dsl: !include-raw-escape: pipeline/docker-publish.groovy

# [EOF]
