# Publish to CodeArtifact

**URL:** <https://bnd.discourse.group/t/publish-to-codeartifact/174>\
**Category:** GENERAL\
**Created:** [October 21, 2021, 11:13am UTC](https://bnd.discourse.group/t/publish-to-codeartifact/174 "2021-10-21T11:13:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brampouwelse](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/brampouwelse/32/35_2.png) [@brampouwelse](https://bnd.discourse.group/u/brampouwelse)\
**Post date:** [October 21, 2021, 11:13am UTC](https://bnd.discourse.group/t/publish-to-codeartifact/174/1 "2021-10-21T11:13:35Z")

</div>

Hi,

For a new workspace I’ve created I’m trying to release some bundles to an AWS CodeArtifact repository but the maven-metadata.xml update is rejected as it’s using 1.0.0.SNAPSHOT as a version which CodeArtifact doesn’t seem to recognise as a snapshot version.

The error I get when running gradle release:

`error : Release my.bundle.jar, into MavenBndRepository [localRepo=/Users/brampouwelse/.m2/repository, storage=Release, inited=true, redeploy=false], exception Could not store my-project/my.bundle/1.0.0.SNAPSHOT/maven-metadata.xml from /Users/brampouwelse/.m2/repository/my-project/my.bundle/1.0.0.SNAPSHOT/maven-metadata-707F2AA1.xml with TaggedData [tag=null, code=400, modified=Thu Jan 01 01:00:00 CET 1970, url=https://my-codeartifact-repo.d.codeartifact.eu-west-1.amazonaws.com/maven/snapshots/my-project/my.bundle/1.0.0.SNAPSHOT/maven-metadata.xml, state=OTHER, msg=maven-metadata.xml has 'version' field declared as '1.0.0.SNAPSHOT' which is not a SNAPSHOT version.This request is intended only for SNAPSHOT versions]`

When consuming a snapshot version from maven bnd automatically changes the version from 1.2.3-SNAPSHOT to 1.2.3.SNAPSHOT, **is there a way to get it to do the same but then the other way around when updating**?

In an attempt to get it to work I’ve tried overriding the version with the -pom instruction, but results in even stranger behaviour 😮

What I’ve added:

```auto

-pom: groupid=com.example, \
  where=META-INF/maven/pom.xml, \
  version=1.2.3-SNAPSHOT

```

The artifacts are uploaded to the maven repo using the version from the bundle version, that version is in the pom I can get from the repo as well, the group id is ignored as well.

Below a snippet of the pom as it’s uploaded to the maven repo (that seems to ignore te -pom instruction) and then the pom as it’s in the bundle jar (that does seem to use the -pom instruction).

maven repo pom:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>my-project</groupId>
  <artifactId>my.bundle</artifactId>
  <version>1.0.0.SNAPSHOT</version>
  <description>my.bundle</description>
  <name>my.bundle</name>

```

bundle pom:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>my.bundle</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <description>my.bundle</description>
  <name>my.bundle</name>

```

I’m still using bnd 5.3.0 and have not yet upgraded to the latest 6.0.0 release.

Hope there is someone here that will come-up with some configuration option I’ve missed 😉

Cheers,

Bram

---

<div class="post-metadata">

**Author:** ![juergen-albert](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/juergen-albert/32/20_2.png) [@juergen-albert](https://bnd.discourse.group/u/juergen-albert)\
**Post date:** [October 21, 2021, 12:20pm UTC](https://bnd.discourse.group/t/publish-to-codeartifact/174/2 "2021-10-21T12:20:11Z")

</div>

Try the following instructions:

```auto
-maven-release: pom
-groupid: com.example
-pom: version=${versionmask;===s;${@version}}	

```

With this the proper pom file will be created and the versionmask macro will correct the Snapshot Version to something maven likes.

---

<div class="post-metadata">

**Author:** ![brampouwelse](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/brampouwelse/32/35_2.png) [@brampouwelse](https://bnd.discourse.group/u/brampouwelse)\
**Post date:** [October 21, 2021, 1:09pm UTC](https://bnd.discourse.group/t/publish-to-codeartifact/174/3 "2021-10-21T13:09:57Z")

</div>

Thanks Jurgen,

That seems to do something, now it trips on another error ☹ that seems to be a case sensitive md5 hash compare in CodeArtifact…

Somehow that was not an issue when I had the other issue 😕

`error : Release my.bundle.jar, into MavenBndRepository [localRepo=/Users/brampouwelse/.m2/repository, storage=Release, inited=true, redeploy=false], exception Could not store com/example/my.bundle/1.0.0-SNAPSHOT/maven-metadata.xml from /Users/brampouwelse/.m2/repository/com/example/my.bundle/1.0.0-SNAPSHOT/maven-metadata-707F2AA1.xml with TaggedData [tag=null, code=400, modified=Thu Jan 01 01:00:00 CET 1970, url=https://my-codeartifact-repo.d.codeartifact.eu-west-1.amazonaws.com/maven/snapshots/com/example/my.bundle/1.0.0-SNAPSHOT/maven-metadata.xml, state=OTHER, msg=Could not publish build '1' of version '1.0.0-SNAPSHOT' because of a content hash mismatch. The 'MD5' content hash of the asset 'my.bundle-1.0.0-20211021.130241-1.pom' is '4ff9a0b81c5e78a7ba7d10c98bd2e9a4' but the value provided in 'my.bundle-1.0.0-20211021.130241-1.pom.md5' is '4FF9A0B81C5E78A7BA7D10C98BD2E9A4']`

---

<div class="post-metadata">

**Author:** ![bjhargrave](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/bjhargrave/32/10_2.png) [@bjhargrave](https://bnd.discourse.group/u/bjhargrave)\
**Post date:** [October 21, 2021, 5:57pm UTC](https://bnd.discourse.group/t/publish-to-codeartifact/174/4 "2021-10-21T17:57:27Z")

</div>

> [@brampouwelse](#):
>
> case sensitive md5 hash compare in CodeArtifact

That seems overly pedantic. I suggest you get the CodeArtifact people to relax this. Nexus accepts uppercase MD5 and SHA1 files.

---

<div class="post-metadata">

**Author:** ![brampouwelse](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/brampouwelse/32/35_2.png) [@brampouwelse](https://bnd.discourse.group/u/brampouwelse)\
**Post date:** [October 21, 2021, 6:26pm UTC](https://bnd.discourse.group/t/publish-to-codeartifact/174/5 "2021-10-21T18:26:18Z")

</div>

It is …

For now I have created some way to get around this … Configured bnd to release to a local repo and then publish to the CodeArtifact repo with some help from bash and maven …

```auto
for pom in `find generated/release -name '*.pom' `; do \ git:master*
  mvn deploy:deploy-file -DpomFile=${pom} \
    -Dfile=${pom/\.pom/\.jar} \
    -DrepositoryId=snapshots \
    -Durl=https://my-repo.d.codeartifact.eu-west-1.amazonaws.com/maven/snapshots/ \
   ; done

```
