TheGuyNextDoor
TheGuyNextDoor

Reputation: 7937

Use custom maven repository when using jfrogcli

I'm using Gitlab and Artifactory for CI/CD.

Access to the internet is restricted and all artifacts are downloaded using/via Artifactory.

I have configured my .gitlab-ci.yml as below to be able to publish build information to Artifactory.

before_script:
  - set M2_HOME=C:\Maven\apache-maven-3.3.9
  - set JFROG_CLI_LOG_LEVEL=DEBUG
  - jfrog rt config --url=%ARTIFACTORY_URL% --user=%ARTIFACTORY_USER% --password=%ARTIFACTORY_PASS%
  - jfrog rt c show
stages:
  - build

build-project:
    stage: build
    script:
      # Run the MVN command
      - jfrog rt mvn "package install -B -U -DskipTests=true" configuration.yml --build-name=my-project --build-number=%CI_JOB_ID%
      # Collect the environment variables
      - jfrog rt bce my-project %CI_JOB_ID%
      # Pass the build information to Artifactory
      - jfrog rt bp my-project %CI_JOB_ID%

In the conf directory of the maven installation i have a custom settings file. This works, i have tried it on the command line.

Unfortunately the command jfrog rt mvn "package install... fails because jfrog cli is trying to directly connect Bintray to download artifacts.

[Info] Running Mvn...
[Debug] Checking prerequisites.
[Info] Downloading jfrog/jfrog-jars/org/jfrog/buildinfo/build-info-extractor-maven3/2.11.1/build-info-extractor-maven3-2.11.1-uber.jar
[Error] Bintray Head https://dl.bintray.com/jfrog/jfrog-jars/org/jfrog/buildinfo/build-info-extractor-maven3/2.11.1/build-info-extractor-maven3-2.11.1-uber.jar: dial tcp 5.153.35.248:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
ERROR: Job failed: exit status 1

Is there a way of configuring jfrog cli to use my custom maven settings?

Is there another way to send build data for a maven project to Artifactory without using jfrog cli?

Upvotes: 1

Views: 1171

Answers (1)

Eyal Ben Moshe
Eyal Ben Moshe

Reputation: 2425

JFrog CLI tries to get only one jar file from jcenter - this is the jar that is used to integrate with maven. If you run the jfrog rt mvn... command from a machine that has internet access, the jar will be download and placed under the ~/.jfrog/dependencies/maven directory. Placing this jar there in advanced will avoid attempting to download it. There's currently work being done in JFrog CLI to imorove this. Follow this issue to get updates about the proposed solution: https://github.com/jfrog/jfrog-cli-go/issues/211

As for additional information options between maven and Artifactory, check out the Maven Artifactory Plugin

Upvotes: 4

Related Questions