Kumar Ashutosh
Kumar Ashutosh

Reputation: 1244

Gitlab CI/CD cross project artifacts not downloading using "needs"

I have a group named my-group which consists of a spring-boot maven project and 2 libraries as below:

   my-group
    |
    ├─> core-lib
    |       ├─> .gitlab-ci.yml
    |       └─> pom.xml 
    ├─> core-sec
    |       ├─> .gitlab-ci.yml
    |       └─> pom.xml 
    └─> user-service
            ├─> .gitlab-ci.yml
            └─> pom.xml 

project user-service is a runnable application which requires core-lib & core-sec as a dependency.

I'm referencing this page: cross-project-artifact-downloads-with-needs

.gitlab-ci.yml for core-lib

cache:
    paths:
      - .m2/repository

variables:
      MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
      MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
      DOCKER_DRIVER: overlay2

image: docker:19.03.1

services:
      - docker:19.03.1-dind

stages:
      - build

mvn_build:
      image: maven:3.3.9-jdk-8
      stage: build
      only:
       - gitlabci-test
      script:
       - "mvn $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true"
      artifacts:
            paths:
            - target/*.jar

.gitlab-ci.yml for user-service:

    cache:
          paths:
          - .m2/repository

    variables:
          MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
          MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
          DOCKER_DRIVER: overlay2

    image: docker:19.03.1

    services:
          - docker:19.03.1-dind

    stages:
          - build

    mvn_build:
          image: maven:3.3.9-jdk-8
          stage: build
          only:
           - gitlabci-test
          script:
           - "mvn $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true"
          artifacts:
                paths:
                - target/*-exec.jar
          needs:
          - project: my-group/core-lib
            job: mvn_build
            ref: gitlabci-test
            artifacts: true

Artifacts for core-lib and core-sec are getting built and uploaded successfully, but while building user-service gitlab runner says:

Could not find artifact com.myproject.core_lib:core-lib:jar:1.1-SNAPSHOT

Please help me with this issue. Thanx

Upvotes: 4

Views: 1362

Answers (1)

Christian Menard
Christian Menard

Reputation: 116

This is a premium feature and not supported on free self-hosted GitLab instances. The documentation did not state this correctly and I ran into the same issue after updating our entire CI workflow. However, the documentation is now updated and marks this as a premium feature. There was also an issue about it, but I cannot find it anymore.

Upvotes: 2

Related Questions