Bamboo specs scanner in 6.2 EAP
Asked by Mat Mannion:

Hi,

We're trying to use the "[Bamboo specs scanner](https://confluence.atlassian.com/bamboo/bamboo-6-2-eap-release-notes-935892071.html#Bamboo6.2EAPReleaseNotes-Repository-storedBambooSpecs)" feature in the 6.2 EAP.

We're stuck at the point of how Bamboo knows there are specs in a project to run, and how it runs them - the configuration of the Linked repository implies that there are plan permissions so I presume it's not just running mvn -Ppublish-specs

It would be particularly useful for us to know how it finds and run the specs, and whether we avoid bundling credential files in the project, as we'd like to include the specs in the development projects themselves.


Answers:
author: Venku Jayanti
body: Alexey - I have similar issue with using bamboo-specs. I do see this in Bamboo home xml-data/repository-specs/REPO_ID directory with log files.The logs show the error:

Unable to scan repository Bamboospec (181403753) for Bamboo Specs  
com.atlassian.bamboo.repository.RepositoryException: Unable to scan repository Bamboospec (181403753) for Bamboo Specs.

I had everything set to what you have mentioned. for me, mvn command works but the git push changes throws the error mentioned earlier. Do you have any suggestions to fix the error. Thanks.

Venku

comments: author: Alexey Chystoprudov
body: Venku, do you have any additional messages in logs?


author: Venku Jayanti
body: Alexey - Thanks for your response. Here is the stack trace

```
[INFO] ------------------------------------------------------------------------[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 3.524 s[INFO] Finished at: 2018-03-26T11:02:06-04:00[INFO] Final Memory: 32M/635M[INFO] ------------------------------------------------------------------------[ERROR] Failed to execute goal com.atlassian.bamboo:bamboo-specs-runner:6.2.5:run (default-cli) on project bamboo-specs-generator: Execution default-cli of goal com.atlassian.bamboo:bamboo-specs-runner:6.2.5:run failed: java.lang.reflect.InvocationTargetException: java.lang.RuntimeException: java.lang.ClassNotFoundException: com.atlassian.bamboo.specs.util.IsolatedYamlizator$$Lambda$11/180084736 -> [Help 1][ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[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/PluginExecutionExceptionUnable to scan repository Bamboospec (181403753) for Bamboo Specscom.atlassian.bamboo.repository.RepositoryException: Unable to scan repository Bamboospec (181403753) for Bamboo Specs at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl.lambda$runSpecs$9(RepositoryStoredSpecsServiceImpl.java:501) at com.atlassian.bamboo.configuration.external.RepositoryStoredSpecsServiceImpl$$Lambda$1930/766619154.call(Unknown Source) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:47) at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) at java.lang.Thread.run(Thread.java:745)Caused by: com.atlassian.utils.process.ProcessException: Non-zero exit code: 1
```


author: Venku Jayanti
body: mvn -Ppublish-specs -X works from me. but anything from git repo gives me the error mentioned in my previous comments


author: Alexey Chystoprudov
body: I would suggest to open support ticket and provide full logs to our support engineers to investigate problem further. From log I see there's ClassNotFoundException, but need to gather more details about environment to understand what's the reason


author: Venku Jayanti
body: Thanks Alexey. Is this a Jira ticket?


author: Alexey Chystoprudov
body: [@Venku Jayanti](/t5/user/viewprofilepage/user-id/1178976) - <https://support.atlassian.com/contact/>


author: Venku Jayanti
body: Support team suggest to upgrade jdk on bamboo server. The reported error got fixed by upgrading to latest version of jdk 8 (bamboo 6.2.5).


author: Alexey Chystoprudov
body: Once you have Bamboo Specs source code which can be executed from your local environment it's now possible to commit java classes and pom.xml to bamboo-specs folder

```
git repo root
  \bamboo-specs
      \src
      | \PlanSpecs.java
      |pom.xml
```

You should not put .credentials file to your repository

Bamboo specs feature should be enabled for Bitbucket Server repository, also to make things easier you should check flag "All projects".

Then push your code and check if in Bamboo home xml-data/repository-specs/REPO_ID you see any files. Also Bamboo will send you email if processing of Bamboo Spec was failed. Email recepient is taken from committer details.

We are working to make this experience better in Bamboo 6.2 GA

comments: author: Mat Mannion
body: Hi Alexey,

Thanks for your advice on this. We still can't seem to get Bamboo to pick this up even from the advice you've given.

The linked repository definitely has the feature flag enabled and "Access all projects" is also set. We've got a working set of specs based off the 6.2.0-eap Maven archetype, though we've changed the parent pom to be version 6.1.1 as 6.2.0-eap doesn't seem to be in Maven central and overridden the version on the two dependencies.

The structure we're left with is:

```
repo root/
??? bamboo-specs/
    ??? src/
    ?   ??? main/
    ?   ?   ??? java/
    ?   ?       ??? DeploySpec.java
    ?   ?       ??? PlanSpec.java
    ?   ??? test/
    ?       ??? java/
    ?           ??? DeploySpecTest.java
    ?           ??? PlanSpecTest.java
    ??? pom.xml
```

If I run mvn -Ppublish-specs from the bamboo-specs directory (with an appropriate .credentials file in place), this works fine, but the Bamboo server doesn't seem to pick anything up - there's no repository-specs directory alongside build-data in the xml-dir directory.

Here's the pom.xml, just for ref:

```
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>

 <parent>
 <groupId>com.atlassian.bamboo</groupId>
 <artifactId>bamboo-specs-parent</artifactId>
 <version>6.1.1</version>
 <relativePath/>
 </parent>

 <groupId>uk.ac.warwick.printercredits</groupId>
 <artifactId>bamboo-specs</artifactId>
 <version>1.0.0-SNAPSHOT</version>
 <packaging>jar</packaging>

 <dependencies>
 <dependency>
 <groupId>com.atlassian.bamboo</groupId>
 <artifactId>bamboo-specs-api</artifactId>
 <version>6.2.0-eap</version>
 </dependency>
 <dependency>
 <groupId>com.atlassian.bamboo</groupId>
 <artifactId>bamboo-specs</artifactId>
 <version>6.2.0-eap</version>
 </dependency>

 <!-- Test dependencies -->
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <scope>test</scope>
 </dependency>
 </dependencies>
</project>
```


author: Alexey Chystoprudov
body: Mat Mannion, sorry for delay,

I think it's better to check Bamboo logs if event from Bitbucket Server correctly sent to Bamboo, then add some debug settings for code which process repository. We can continue here or you can create support request at support.atlassian.com and our Support engineers will help you or pass it to dev team for investigation. As you know it's new feature and we expect that similar cases will help us to make feature valuable and usable.