Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

bitbucket pipeline src/main/java file fetch issue

Aditya Dhatingan August 28, 2023

I have a maven project (JAVA)


ChatGPT-BitbucketIntegration:
      - step:
          script:
            - echo "System Information:"
            - uname -a
            - echo "OS Information:"
            - cat /etc/os-release
            - echo "Commit ID is $BITBUCKET_COMMIT"
            - mvn exec:java -DcommitId="$BITBUCKET_COMMIT"
This is script of pipeline.

The pom.xml file contains 
<plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>bitbucket.CommitCommenter</mainClass>
                    <arguments>
                        <argument>${commitId}</argument>
                    </arguments>
                    <includeProjectDependencies>true</includeProjectDependencies>
                </configuration>
            </plugin>

I am calling the main class in the pipeline script
using command mvn exec:java -DcommitId= "<commitId>"
When I am running the same file locally there is no issue. But on pipeline I am facing the issue 
[WARNING]
14657
java.lang.ClassNotFoundException: bitbucket.CommitCommenter
14658
at java.net.URLClassLoader.findClass (URLClassLoader.java:433)
14659
at java.lang.ClassLoader.loadClass (ClassLoader.java:586)
14660
at java.lang.ClassLoader.loadClass (ClassLoader.java:519)
14661
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:246)
14662
at java.lang.Thread.run (Thread.java:831)

Note: I have two java packages in repository

src.main.java

and 

src.test.java

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2023

Hey @Aditya Dhatingan and thank you for reaching out to Community!

Maven framework falls a little outside of my expertise, but since pipeline builds run inside docker containers,  I would suggest in your case to try debugging your pipeline locally with docker to troubleshoot the issue and check if you can identify the fix. With this, you are able to reproduce a local environment very close to pipelines.

If you are able to find the solution to fix the error locally by testing with docker, then you can push the changes to your bitbucket repository and the pipeline should complete successfully as well.

Thank you, @Aditya Dhatingan !

Patrik S

Aditya Dhatingan September 18, 2023

Thanks @Patrik S .

This issue is sloved

Since I was not compiling the code first, bitbucket was not able to find the file. (mvn compile worked)

ChatGPT-BitbucketIntegration:
      - step:
          script:
            - echo "System Information:"
            - uname -a
            - echo "OS Information:"
            - cat /etc/os-release
            - echo "Commit ID is $BITBUCKET_COMMIT"
            - mvn compile 
            - mvn exec:java -DcommitId="$BITBUCKET_COMMIT"
Like Patrik S likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events