Currently there is no automated process for releasing from Artifactory to Maven-Central so we need to use a custom script (the JFrog CLI currently doesn't support the required endpoints).
This script assumes you have already pushed from Artifactory (or whatever your artifact store is), to Bintray, the package has been requested and included in JCenter, and that it has not already been synced to Maven Central.
If your package has not been included in JCenter yet, follow this guide from JFrog (Note: You'll need to used the 'Old' UI in order to see the options detailed in that guide. See this StackOverflow post for directions on how to get to the Old UI).
#!/bin/bash # Requirements: # - curl # - jq BINTRAY_USER=$username BINTRAY_TOKEN="ABCDEFG12345" BINTRAY_ORG=$organization BINTRAY_PROJECT=$project VERSION=$release_version if [ "$BINTRAY_TOKEN" == "" ]; then exit 1 fi function list_packages () { local URL="https://api.bintray.com/repos/$BINTRAY_ORG/$BINTRAY_PROJECT/packages" { curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L $URL | jq '.[] | .name' | tr -d '"'; # paginated to grab between 300-350 packages curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L "$URL/?start_pos=50" | jq '.[] | .name' | tr -d '"'; curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L "$URL/?start_pos=100" | jq '.[] | .name' | tr -d '"'; curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L "$URL/?start_pos=150" | jq '.[] | .name' | tr -d '"'; curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L "$URL/?start_pos=200" | jq '.[] | .name' | tr -d '"'; curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L "$URL/?start_pos=250" | jq '.[] | .name' | tr -d '"'; curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L "$URL/?start_pos=300" | jq '.[] | .name' | tr -d '"' curl -u $BINTRAY_USER:$BINTRAY_TOKEN -L "$URL/?start_pos=350" | jq '.[] | .name' | tr -d '"' } >> tmp_packages.txt sort tmp_packages.txt | uniq > packages_$VERSION.txt } function sync_packages () { if [ ! -f packages.txt ]; then echo "packages.txt file missing" exit 1 fi while read -r package_name; do sync_package $package_name $VERSION ; done < packages.txt } # Needs package name, version function sync_package () { local package_name=$1 local package_version=$2 echo "Syncing $package_name:$package_version" curl \ -u $BINTRAY_USER:$BINTRAY_TOKEN \ -H "Content-Type: application/json" \ -X POST \ -d '{"close":"1"}' \ -L "https://api.bintray.com/maven_central_sync/$BINTRAY_ORG/$BINTRAY_PROJECT/$package_name/versions/$package_version" echo } #list_packages sync_packages #sync_package $1 $VERSION
Step-by-step guide
The script above needs some environment variables set and then can be run in a screen session (expect 1-2 minutes per package), to sync from Bintray to JCenter and Maven Central.
- You need to create a Bintray account and create a support ticket to be added to your respective organization.
- Once there, you'll need an API key on Bintray (Profile → API Key)
- Fill out the environment variables and then run the script to sync.
Related articles