Hi there,
I am after step to deploy new jars into artifactory using maven.
Currently I am using below approach calling artifactory API. However I need to do additional stuff to check the current versions of jars in the artifactory and incresed to new version via several commands lik below
Just wondering whether there is a more straight forward implementaion to this?
type or paste code here publish_artifact:
stage: build image
type: freestyle
title: "Deploy Libs to Artifactory"
arguments:
image: 'hub.artifactory.gcp.xxxx/curlimages/curl:latest'
commands:
- LIB_FOLDERS=${{PUBLISH_LIBS}}
- LIBS_PATH=${{PUBLISH_LIBS_PATH}}
- echo ${{LIB_GROUP_ID}}
- echo ${{LIB_ARTIFACT_ID}}
- GET_LATEST_VERSION=$(curl -v -H "Authorization:Bearer "${{TOKEN}} -X GET "https://artifactory.gcp.xxx:443/artifactory/api/search/latestVersion?g=${{LIB_GROUP_ID}}&a=${{LIB_ARTIFACT_ID}}&v=&remote=1&repos=insto-virtual")
- echo $GET_LATEST_VERSION
- CURRENT_LIB_VERSION=$(echo $GET_LATEST_VERSION | awk -F"-" '{print $1}')
- echo $CURRENT_LIB_VERSION
- (echo "${CURRENT_LIB_VERSION:0:8}" | tr -d '\r' | grep -Eq "^[0-9]{2}.[0-9].[0-9].[0-9]$") && echo "${VERSION_FLAG=true}" echo "valid current version" || "${VERSION_FLAG=false}" echo "Invalid current version"
- echo $VERSION_FLAG
- if [ "$VERSION_FLAG" != true ]; then echo "No proper version found..."; exit; else NEW_LIB_VERSION=$(echo "$CURRENT_LIB_VERSION" | awk 'BEGIN{FS=OFS="."} {$4+=1} 1'); fi
- echo $NEW_LIB_VERSION
- >
for LIB_FOLDER in $LIB_FOLDERS;
do
FILE_PATH="${{APP_NAME}}/$LIB_FOLDER/target/*.jar"
ARTIFACTORY_URL="https://artifactory.gcp.xxx:443/artifactory/$LIBS_PATH/$LIB_FOLDER/$NEW_LIB_VERSION-$(date +'%Y-%m-%d')-${{CF_SHORT_REVISION}}/$LIB_FOLDER-$NEW_LIB_VERSION-$(date +'%Y-%m-%d')-${{CF_SHORT_REVISION}}.jar"
curl -v -H X-JFrog-Art-Api:${{TOKEN}} -T $FILE_PATH -X PUT $ARTIFACTORY_URL;
done```
So I hope if I have maven process I wouldnt need to all these addtional shell command to implement this.
I came across below links, but not quite sure it does the same thing
https://codefresh.io/blog/deploying-to-jfrog-bintray/
https://codefresh.io/docs/docs/example-catalog/ci-examples/publish-jar/