Deploy jars to artifactory using maven

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"
      image: 'hub.artifactory.gcp.xxxx/curlimages/curl:latest'
      - echo ${{LIB_GROUP_ID}}
      - echo ${{LIB_ARTIFACT_ID}}
      - GET_LATEST_VERSION=$(curl -v -H "Authorization:Bearer "${{TOKEN}} -X GET "${{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: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;
         curl -v -H X-JFrog-Art-Api:${{TOKEN}} -T $FILE_PATH -X PUT $ARTIFACTORY_URL;

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


The links you have found are correct. You should not use a Codefresh step for this. You should use directly Maven and/or Gradle and then have a simple Codefresh pipeline that calls the whole thing

Alternatively you should use the Jfrog CLI.

Make sure that everything works locally first BEFORE creating the Codefresh pipeline

Thanks for your reply.

Not sure I understood what you suggested here.
Actually I am using this step as part our build pipeline. So should have a pipeline step to publish jars in addition to other steps git clone/build/run test etc. I am using maven here.

The pipeline should just call “maven publish”.

The step you posted is a raw curl call.

Let me put it in other words. Forget Codefresh for a moment.

Can you upload the package from your terminal with just JDK/Maven and proper parameters? Once you have that done THEN transfer the command to a Codefresh freestyle step