Unable to publish artifact
Asked by ldp920:

build 02-??-2020 15:31:31 \[INFO\] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ cschm ---  
build 02-??-2020 15:31:31 \[INFO\] Not copying test resources  
build 02-??-2020 15:31:31 \[INFO\]  
build 02-??-2020 15:31:31 \[INFO\] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ cschm ---  
build 02-??-2020 15:31:31 \[INFO\] Not compiling test sources  
build 02-??-2020 15:31:31 \[INFO\]  
build 02-??-2020 15:31:31 \[INFO\] --- maven-surefire-plugin:2.22.1:test (default-test) @ cschm ---  
build 02-??-2020 15:31:32 \[INFO\] Tests are skipped.  
build 02-??-2020 15:31:32 \[INFO\]  
build 02-??-2020 15:31:32 \[INFO\] --- maven-jar-plugin:3.1.1:jar (default-jar) @ cschm ---  
build 02-??-2020 15:31:33 \[INFO\] Building jar: D:\\install_pack\\bamboo\\xml-data\\build-dir\\PROJ-PLAN-JOB1\\target\\cschm.jar  
build 02-??-2020 15:31:33 \[INFO\]  
build 02-??-2020 15:31:33 \[INFO\] --- spring-boot-maven-plugin:2.1.4.RELEASE:repackage (repackage) @ cschm ---  
build 02-??-2020 15:31:36 \[INFO\] Replacing main artifact with repackaged archive  
build 02-??-2020 15:31:36 \[INFO\] ------------------------------------------------------------------------  
build 02-??-2020 15:31:36 \[INFO\] BUILD SUCCESS  
build 02-??-2020 15:31:36 \[INFO\] ------------------------------------------------------------------------  
build 02-??-2020 15:31:36 \[INFO\] Total time: 28.904 s  
build 02-??-2020 15:31:36 \[INFO\] Finished at: 2020-04-02T15:31:36+08:00  
build 02-??-2020 15:31:36 \[INFO\] ------------------------------------------------------------------------  
simple 02-??-2020 15:31:36 Parsing test results under D:\\install_pack\\bamboo\\xml-data\\build-dir\\PROJ-PLAN-JOB1...  
simple 02-??-2020 15:31:36 Finished task 'Maven Build' with result: Success  
simple 02-??-2020 15:31:36 Running post build plugin 'NCover Results Collector'  
simple 02-??-2020 15:31:36 Running post build plugin 'Artifact Copier'  
simple 02-??-2020 15:31:36 Publishing an artifact: cschm  
error 02-??-2020 15:31:36 Unable to publish artifact \[cschm\]:  
error 02-??-2020 15:31:36 The artifact is required, build will now fail.  
simple 02-??-2020 15:31:36 The artifact hasn't been successfully published after 3.982 ms  
simple 02-??-2020 15:31:36 Running post build plugin 'npm Cache Cleanup'  
simple 02-??-2020 15:31:36 Running post build plugin 'Clover Results Collector'  
simple 02-??-2020 15:31:36 Running post build plugin 'Docker Container Cleanup'  
simple 02-??-2020 15:31:36 Finalising the build...  
simple 02-??-2020 15:31:36 Stopping timer.  
simple 02-??-2020 15:31:36 Build PROJ-PLAN-JOB1-3 completed.  
simple 02-??-2020 15:31:36 Running on server: post build plugin 'NCover Results Collector'  
simple 02-??-2020 15:31:36 Running on server: post build plugin 'Build Hanging Detection Configuration'  
simple 02-??-2020 15:31:36 Running on server: post build plugin 'Clover Delta Calculator'  
simple 02-??-2020 15:31:36 Running on server: post build plugin 'Maven Dependencies Postprocessor'  
simple 02-??-2020 15:31:36 All post build plugins have finished  
simple 02-??-2020 15:31:36 Generating build results summary...  
simple 02-??-2020 15:31:36 Saving build results to disk...  
simple 02-??-2020 15:31:38 Store variable context...  
simple 02-??-2020 15:31:38 Indexing build results...  
simple 02-??-2020 15:31:38 Finished building PROJ-PLAN-JOB1-3.


Answers:
author: Gerhard Forster
body: Hi [@ldp920](/t5/user/viewprofilepage/user-id/3841960),

Thanks for reaching us out via this support channel. We're happy to assist you on the artifact sharing issue that you're facing.

Bamboo supports basically 3 types of artifact sharing mechanisms, all outlined in KB [Sharing artifacts](https://confluence.atlassian.com/bamboo/sharing-artifacts-359400060.html "Sharing artifacts"). These are:

* Sharing an artifact betweeen jobs of the same build but on different stages, like one "build stage producing an artifact, and this artifact being "consumed" by a "test" stage.
* Artifacts can get shared between different build plans.
* And they can also and logically be shared between a build plan and a deplyment environment.

In all of these cases an artifact needs to first be defined on "producer" side and then be copied over to a "consumer", be it another job, another build or a deployment.

The process being used for sharing and publishing an artifact, especially between the first and the other two sharing options, do differ.

Thus, in a first step, please check out the above KB for what's your use case and as of that, please cross-check your configuration per what the above KB describes. In case you spot any configuration error, kindly correct it and run the build again so to see if things are sorted out.

Now let me get to your posted Bamboo build log. It indicates the following with regards to the mentioned mis-behavior:

```
simple 02-??-2020 15:31:36 Publishing an artifact: cschm
error 02-??-2020 15:31:36 Unable to publish artifact [cschm]:
```

So this tells us that an artifact defined as "cschm" cannot be published. Logically that can have a series of reasons:

1. The artifact is not produced, thus is physically does not exist and so cannot be shared.
2. An artifact is produced, but but its definition does not match reality. That might be due to name, location or "copy pattern" defined for the artifact are not correct.
3. If the above is fulfilled, an artifact should get copied out. Hence it should get copied in on "consumer" side. Not being able to do so, might also cause the process to fail.
4. And lastl but not least, the download may be configured incorrectly, such as artifact name not matching with "producer", source plan wrong or possibly destination path not existing.

Now let me get back to your build log. It also presents the below message before trying to share.

```
build 02-??-2020 15:31:36 [INFO] Replacing main artifact with repackaged archive
```

So as per this and previous log lines, it seems as if the originally intended could not be compiled! Nonetheless, some replacement appears to have been packaged. Now we wonder:

* Is an artifact really created in your source respectively on "producer" side? That's tackling point 1 from above.
* If so, does the so-called "repackaged archive" match up with your artifact definition? If not, in accordance with point 2 from above, nothing can be shared too.
* And if so too, you may want to check if that artifact really arrives at destination, so on "consumer" side.

The latter you may check on file system level or e.g. by adding a Bamboo Script task to your "consumer" plan or deployment with the following for Linux

```
ls -al ${bamboo.build.working.directory}
```

or the below in a Windows CMD box

```
dir ${bamboo.build.working.directory}
```

which prints out the content of this Bamboo plan's working directory. If the download succeeded, you should find the artifact there.

We hope this helps you out. If not, please let us know where you get stuck, preferably in this same thread.

Thanks and cheers,  
Gerhard