1

I am looking to run PMD checks on the modified files that are being pushed into Stash. The push should fail if the PMD check fails.

From what I have read I have deduced that these checks have to be done in a pre-receive repository hook. I have created a repository plugin using the atlassian-plugin-sdk but I find it difficult to find out the relevant classes which would help me to perform the said operation.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Naveen Dennis
  • 1,223
  • 3
  • 24
  • 39

1 Answers1

2

This may or may not help.

https://bitbucket.org/atlassianlabs/stash-filesize-hook-plugin/

And you may also require the ContentService:

https://developer.atlassian.com/static/javadoc/stash/latest/api/reference/com/atlassian/stash/content/ContentService.html

That said I would strongly advise you not to run PMD (or things like that) in a pre-receive hook. While convenient, it's going to make your pushes to Stash extremely slow. Instead, my advice would be to restrict pushes to master, and run branch builds across your PRs. The builds can run PMD and whatever other code checks you like, pushing the results back to Stash when they're done. Stash also has a setting that requires PRs have at least one green build.

Again, you may want to consider heading over to Answers as that has a bigger community built around Atlassian questions.

charleso
  • 1,816
  • 14
  • 12