Publishing packages with curl
This section shows how to use the HTTP client curl
to publish Maven
packages to a CodeCatalyst package repository. Publishing packages with curl
can
be useful if you do not have or want to install the Maven client in your
environments.
To publish a Maven package with curl
-
You must store a personal access token (PAT) into an environment variable to authenticate
curl
with CodeCatalyst. If you already have one, you can use that. If not, you can create one and configure the environment variable.-
Create a PAT by following the steps in Grant users repository access with personal access tokens. Copy the PAT to store it in an environment variable.
-
On your local machine's command line, configure an environment variable with your PAT.
export CodeCatalyst_ARTIFACTS_TOKEN=
your_PAT
-
-
Use the following
curl
command to publish the JAR to a CodeCatalyst repository. Replaceusername
,space_name
,proj_name
, andrepo_name
with your CodeCatalyst user name, space name, project name, and package repository name.curl --request PUT https://packages.
region
.codecatalyst.aws/maven/space-name
/proj-name
/repo-name
/com
/mycompany
/app
/my-app
/1.0
/my-app-1.0.jar
\ --user "username
:CodeCatalyst_ARTIFACTS_TOKEN" --header "Content-Type: application/octet-stream" \ --data-binary @target/path
/to
/my-app-1.0.jar
-
Use the following
curl
command to publish the POM to a CodeCatalyst repository. Replaceusername
,space_name
,proj_name
, andrepo_name
with your CodeCatalyst user name, space name, project name, and package repository name.curl --request PUT https://packages.
region
.codecatalyst.aws/maven/space-name
/proj-name
/repo-name
/com
/mycompany
/app
/my-app
/1.0
/my-app-1.0.pom
\ --user "username
:CodeCatalyst_ARTIFACTS_TOKEN" --header "Content-Type: application/octet-stream" \ --data-binary @target/my-app-1.0.pom
-
At this point, the Maven package will be in your CodeCatalyst repository with a status of
Unfinished
. To be able to consume the package, it must be in thePublished
state. You can move the package fromUnfinished
toPublished
by either uploading amaven-metadata.xml
file to your package, or changing the status in the CodeCatalyst console.-
Option 1: Use the following
curl
command to add amaven-metadata.xml
file to your package. Replaceusername
,space_name
,proj_name
, andrepo_name
with your CodeCatalyst user name, space name, project name, and package repository name.curl --request PUT https://packages.
region
.codecatalyst.aws/maven/space-name
/proj-name
/repo-name
/com
/mycompany
/app
/my-app
/maven-metadata.xml
\ --user "username
:CodeCatalyst_ARTIFACTS_TOKEN" --header "Content-Type: application/octet-stream" \ --data-binary @target/maven-metadata.xml
Following is an example of the contents of a
maven-metadata.xml
file:<metadata modelVersion="1.1.0"> <groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <versioning> <latest>1.0</latest> <release>1.0</release> <versions> <version>1.0</version> </versions> <lastUpdated>20200731090423</lastUpdated> </versioning> </metadata>
-
Option 2: Update the package status to
Published
in the CodeCatalyst console. For information about how to update a package version's status, see Updating a package version's status.
-
If you only have a package's JAR file, you can publish a consumable package version to
a CodeCatalyst repository using mvn
. This can be useful if you do not have access
to the package's source code or POM. See Publishing third-party
packages for details.