rnc: :+1: 
diff --git a/cekit/builders/osbs.py b/cekit/builders/osbs.py
index 38f2b1d..9048a3d 100644
--- a/cekit/builders/osbs.py
+++ b/cekit/builders/osbs.py
@@ -116,11 +116,11 @@ class OSBSBuilder(Builder):
         self.dist_git.clean()
 
         # First get all artifacts that are not plain artifacts
-        self.artifacts = [a['name']
+        self.artifacts = [a.target_file_name()
                           for a in descriptor.all_artifacts if not isinstance(a, _PlainResource)]
         # When plain artifact was handled using lookaside cache, we need to add it too
         # TODO Rewrite this!
-        self.artifacts += [a['name']
+        self.artifacts += [a.target_file_name()
                            for a in descriptor.all_artifacts if isinstance(a, _PlainResource) and a.get('lookaside')]
 
         if 'packages' in descriptor and 'set_url' in descriptor['packages']:

OSBS builder doesn't work well with plain artifacts with target set
It uses the `name` attribute instead of `target` if available.
diff --git a/tests/test_builder.py b/tests/test_builder.py
index d72a6e1..9e44f79 100644
--- a/tests/test_builder.py
+++ b/tests/test_builder.py
@@ -12,8 +12,13 @@ except ImportError:
     from mock import call
 
 from cekit.builder import Builder
+from cekit.config import Config
+from cekit.descriptor import Image
 from cekit.errors import CekitError
 
+config = Config()
+config.cfg['common'] = {'redhat': True}
+
 
 def test_osbs_builder_defaults(mocker):
     mocker.patch.object(subprocess, 'check_output')
@@ -130,6 +135,16 @@ class DistGitMock(object):
     def stage_modified(self):
         pass
 
+    @staticmethod
+    def repo_info(path):
+        pass
+
+    def prepare(self, stage, user=None):
+        pass
+
+    def clean(self):
+        pass
+
 
 def create_osbs_build_object(mocker, builder_type, params={}):
     mocker.patch('cekit.tools.decision')
@@ -329,6 +344,98 @@ def test_osbs_wait_for_osbs_task_failed(mocker):
     sleep.assert_not_called()
 
 
+@pytest.mark.parametrize('artifact,src,target', [
+    (
+        {
+            'path': 'some-path.jar',
+            'md5': 'aaabbb'
+        },
+        'image/some-path.jar',
+        'osbs/repo/some-path.jar'
+    ),
+    (
+        {
+            'name': 'some-name',
+            'path': 'some-path.jar',
+            'md5': 'aaabbb'
+        },
+        'image/some-name',
+        'osbs/repo/some-name'
+    ),
+    (
+        {
+            'target': 'some-target.jar',
+            'path': 'some-path.jar',
+            'md5': 'aaabbb'
+        },
+        'image/some-target.jar',
+        'osbs/repo/some-target.jar'
+    ),
+    (
+        {
+            'name': 'some-name',
+            'md5': 'aaabbb'
+        },
+        'image/some-name',
+        'osbs/repo/some-name'
+    ),
+    (
+        {
+            'name': 'some-name',
+            'target': 'some-target.jar',
+            'md5': 'aaabbb'
+        },
+        'image/some-target.jar',
+        'osbs/repo/some-target.jar'
+    )
+])
+def test_osbs_copy_artifacts_to_dist_git(mocker, tmpdir, artifact, src, target):
+    os.makedirs(os.path.join(str(tmpdir), 'image'))
+
+    copy_mock = mocker.patch('cekit.builders.osbs.shutil.copy')
+
+    dist_git_class = mocker.patch('cekit.builders.osbs.DistGit')
+    dist_git_class.return_value = DistGitMock()
+
+    config.cfg['common'] = {'redhat': True, 'work_dir': str(tmpdir)}
+
+    image_descriptor = {
+        'schema_version': 1,
+        'from': 'centos:latest',
+        'name': 'test/image',
+        'version': '1.0',
+        'labels': [{'name': 'foo', 'value': 'bar'}, {'name': 'labela', 'value': 'a'}],
+        'osbs': {
+            'repository': {
+                'name': 'repo',
+                'branch': 'branch'
+            }
+        },
+        'artifacts': [
+            artifact
+        ]
+    }
+
+    image = Image(image_descriptor, os.path.dirname(os.path.abspath(str(tmpdir))))
+
+    # TODO Rewrite this
+    # This is only to mark that the plain artifact was not available in koji
+    # So we need to add it to lookaside cache. This does not hurt non-plain artifacts, so we
+    # can add it for all artifacts
+    image.artifacts[0]['lookaside'] = True
+
+    builder = create_osbs_build_object(mocker, 'osbs')
+    builder.target = str(tmpdir)
+    builder.prepare(image)
+    dist_git_class.assert_called_once_with(os.path.join(
+        str(tmpdir), 'osbs', 'repo'), str(tmpdir), 'repo', 'branch')
+
+    calls = [mocker.call('Dockerfile', os.path.join(str(tmpdir), 'osbs/repo/Dockerfile')),
+             mocker.call(os.path.join(str(tmpdir), src), os.path.join(str(tmpdir), target))]
+
+    copy_mock.assert_has_calls(calls)
+
+
 def test_docker_builder_defaults():
     params = {'tags': ['foo', 'bar']}
     builder = Builder('docker', 'tmp', params)

pip install -e .[dev]
parse_log_pytest
requirements.txt
behave lxml mock pytest pytest-cov pytest-mock docker docker-squash
apt-get update apt-get install -y gcc
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
behave==1.2.6
-e git+https://github.com/cekit/cekit.git@465639868991cca6a6db532623d7ef5d538675d0#egg=cekit
certifi==2025.1.31
charset-normalizer==3.4.1
colorlog==6.9.0
coverage==7.8.0
docker==7.1.0
docker-squash==1.2.2
docopt==0.6.2
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
Jinja2==3.1.6
lxml==5.3.1
MarkupSafe==3.0.2
mock==5.2.0
packaging==24.2
parse==1.20.2
parse_type==0.6.4
pluggy==1.5.0
pykwalify==1.8.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-mock==3.14.0
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.12
six==1.17.0
tomli==2.2.1
urllib3==2.3.0

name: cekit
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - pip=25.0=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - behave==1.2.6
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - colorlog==6.9.0
      - coverage==7.8.0
      - docker==7.1.0
      - docker-squash==1.2.2
      - docopt==0.6.2
      - exceptiongroup==1.2.2
      - idna==3.10
      - iniconfig==2.1.0
      - jinja2==3.1.6
      - lxml==5.3.1
      - markupsafe==3.0.2
      - mock==5.2.0
      - packaging==24.2
      - parse==1.20.2
      - parse-type==0.6.4
      - pluggy==1.5.0
      - pykwalify==1.8.0
      - pytest==8.3.5
      - pytest-cov==6.0.0
      - pytest-mock==3.14.0
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - requests==2.32.3
      - ruamel-yaml==0.18.10
      - ruamel-yaml-clib==0.2.12
      - six==1.17.0
      - tomli==2.2.1
      - urllib3==2.3.0
prefix: /opt/conda/envs/cekit

tests/test_builder.py::test_osbs_copy_artifacts_to_dist_git[artifact2-image/some-target.jar-osbs/repo/some-target.jar] tests/test_builder.py::test_osbs_copy_artifacts_to_dist_git[artifact4-image/some-target.jar-osbs/repo/some-target.jar]
tests/test_builder.py::test_osbs_builder_defaults tests/test_builder.py::test_osbs_builder_redhat tests/test_builder.py::test_osbs_builder_use_rhpkg_staget tests/test_builder.py::test_osbs_builder_custom_commit_msg tests/test_builder.py::test_osbs_builder_nowait tests/test_builder.py::test_osbs_builder_user tests/test_builder.py::test_merge_container_yaml_no_limit_arch tests/test_builder.py::test_merge_container_yaml_limit_arch tests/test_builder.py::test_osbs_builder_run_brew_stage tests/test_builder.py::test_osbs_builder_run_brew tests/test_builder.py::test_osbs_builder_run_koji tests/test_builder.py::test_osbs_builder_run_brew_nowait tests/test_builder.py::test_osbs_builder_run_brew_user tests/test_builder.py::test_osbs_builder_run_brew_target tests/test_builder.py::test_osbs_wait_for_osbs_task_finished_successfully tests/test_builder.py::test_osbs_wait_for_osbs_task_in_progress tests/test_builder.py::test_osbs_wait_for_osbs_task_failed tests/test_builder.py::test_osbs_copy_artifacts_to_dist_git[artifact0-image/some-path.jar-osbs/repo/some-path.jar] tests/test_builder.py::test_osbs_copy_artifacts_to_dist_git[artifact1-image/some-name-osbs/repo/some-name] tests/test_builder.py::test_osbs_copy_artifacts_to_dist_git[artifact3-image/some-name-osbs/repo/some-name] tests/test_builder.py::test_docker_builder_defaults tests/test_builder.py::test_docker_squashing_enabled tests/test_builder.py::test_docker_squashing_disabled tests/test_builder.py::test_docker_squashing_parameters tests/test_builder.py::test_buildah_builder_run tests/test_builder.py::test_buildah_builder_run_pull
cekit/builders/osbs.py
cekit/builders/osbs.py