Bitbucket Pipeline Failure : Could not resolve dependencies for project ABC.. DependencyResolutionException

Viewed 607

I have created a bitbucket pipeline to build test and deploy. I've used some artifacts which are not part of the maven central. I have put those artifacts in the basedir/repo folder and configured them in the pom file for maven to search for it. All the artifacts are in the repo folder. I can use them and generate maven build successfully in local machine. But it fails in the bitbucket pipeline.

pom.xml file

      <repositories>
            <repository>
                <id>project.local</id>
                <name>xxx</name>
                <url>file:${project.basedir}/repo</url>
            </repository>
        </repositories>

bitbucket-pipelines.yml

 image: maven:3.3.9
    
    pipelines:
      default:
        - parallel:
          - step:
              name: Build, Test and Deploy
              caches:
                - maven
              script:
                - echo $BITBUCKET_CLONE_DIR # Debug: Print the $BITBUCKET_CLONE_DIR
                - pwd # Debug: Print the current working directory
                - mvn clean test -X
                - git push https://heroku:$HEROKU_API_KEY@git.heroku.com/$HEROKU_APP_NAME.git HEAD
                - kill -9 $(lsof -t -i:8080 -sTCP:LISTEN)     
              artifacts: # defining the artifacts to be passed to each future step.
              - lib/*.txt
              - repo/**
              after-script:
                  # Collect checkstyle results, if any, and convert to Bitbucket Code Insights.
                - pipe: atlassian/checkstyle-report:0.2.0
          - step:
              name: Security Scan
              script:
                # Run a security scan for sensitive data.
                # See more security tools at https://bitbucket.org/product/features/pipelines/integrations?&category=security
                - pipe: atlassian/git-secrets-scan:0.4.

Sure that I'm missing some configuration. Please help me fix it. Below is the error I'm getting

[DEBUG] Writing tracking file /root/.m2/repository/org/hamcrest/hamcrest-core/2.1/hamcrest-core-2.1.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/testcontainers/testcontainers/1.15.1/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/testcontainers/testcontainers/1.15.1/testcontainers-1.15.1.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/apache/commons/commons-compress/1.20/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/apache/commons/commons-compress/1.20/commons-compress-1.20.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/rnorth/duct-tape/duct-tape/1.0.8/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/rnorth/duct-tape/duct-tape/1.0.8/duct-tape-1.0.8.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/rnorth/visible-assertions/visible-assertions/2.1.2/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/rnorth/visible-assertions/visible-assertions/2.1.2/visible-assertions-2.1.2.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/net/java/dev/jna/jna/4.5.2/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/net/java/dev/jna/jna/4.5.2/jna-4.5.2.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/com/github/docker-java/docker-java-api/3.2.7/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/com/github/docker-java/docker-java-api/3.2.7/docker-java-api-3.2.7.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/com/github/docker-java/docker-java-transport-zerodep/3.2.7/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/com/github/docker-java/docker-java-transport-zerodep/3.2.7/docker-java-transport-zerodep-3.2.7.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/com/github/docker-java/docker-java-transport/3.2.7/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/com/github/docker-java/docker-java-transport/3.2.7/docker-java-transport-3.2.7.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/testcontainers/junit-jupiter/1.15.2/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/testcontainers/junit-jupiter/1.15.2/junit-jupiter-1.15.2.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.5.2/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.5.2/junit-jupiter-api-5.5.2.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/apiguardian/apiguardian-api/1.1.0/apiguardian-api-1.1.0.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/opentest4j/opentest4j/1.2.0/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/junit/platform/junit-platform-commons/1.5.2/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/junit/platform/junit-platform-commons/1.5.2/junit-platform-commons-1.5.2.jar.lastUpdated
[DEBUG] Writing tracking file /root/.m2/repository/org/testcontainers/mongodb/1.15.1/_remote.repositories
[DEBUG] Writing tracking file /root/.m2/repository/org/testcontainers/mongodb/1.15.1/mongodb-1.15.1.jar.lastUpdated
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.346 s
[INFO] Finished at: 2021-07-10T08:00:01+00:00
[INFO] Final Memory: 24M/450M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project tt-controller: Could not resolve dependencies for project com.tt:tt-controller:jar:1.0.0: The following artifacts could not be resolved: com.tt:email-sender:jar:1.1 : Could not find artifact com.tt:email-sender:jar:1.1 in project.local (file:/opt/atlassian/pipelines/agent/build/repo) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project tt-controller: Could not resolve dependencies for project com.tt:tt-controller:jar:1.0.0: The following artifacts could not be resolved: com.tt:email-sender:jar:1.1 : Could not find artifact com.tt:email-sender:jar:1.1 in project.local (file:/opt/atlassian/pipelines/agent/build/repo)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:245)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:199)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.tt:tt-controller:jar:1.0.0: The following artifacts could not be resolved: com.tt:email-sender:jar:1.1: Could not find artifact com.tt:email-sender:jar:1.1 in project.local (file:/opt/atlassian/pipelines/agent/build/repo)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:211)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
    ... 23 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: The following artifacts could not be resolved: com.tt:email-sender:jar:1.1: Could not find artifact com.tt:email-sender:jar:1.1 in project.local (file:/opt/atlassian/pipelines/agent/build/repo)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:205)
    ... 24 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: com.tt:email-sender:jar:1.1: Could not find artifact com.tt:email-sender:jar:1.1 in project.local (file:/opt/atlassian/pipelines/agent/build/repo)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
    ... 25 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.tt:email-sender:jar:1.1 in project.local (file:/opt/atlassian/pipelines/agent/build/repo)
    at org.eclipse.aether.connector.basic.ArtifactTransportListener.transferFailed(ArtifactTransportListener.java:39)
    at org.eclipse.aether.connector.basic.BasicRepositoryConnector$TaskRunner.run(BasicRepositoryConnector.java:355)
    at org.eclipse.aether.util.concurrency.RunnableErrorForwarder$1.run(RunnableErrorForwarder.java:67)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

By default it is looking for the /repo in the "file:/opt/atlassian/pipelines/agent/build/repo". But the dependencies are in the project folder/repo. How can I point/change the basedir in the pipeline?

Can I put the dependencies in the file:/opt/atlassian/pipelines/agent/build/repo location. Where can I find that location?

Please find the project structure in the below image enter image description here

0 Answers
Related