Comments (12)
Do you have an example of where it does not work?
from violation-comments-to-stash-plugin.
For now I need to manually specify projectKey and repoSlug:
if (env.CHANGE_ID) {
step([$class: 'ViolationsToBitbucketServerRecorder',
config: [useUsernamePasswordCredentials : true,
projectKey : 'prokey',
repoSlug : 'repository-name',
pullRequestId : env.CHANGE_ID,
commentOnlyChangedContent : false,
commentOnlyChangedContentContext : 0,
createCommentWithAllSingleFileComments: false,
createSingleFileComments : true,
violationConfigs : [[pattern : '.*/checkstyle-result\\.xml$',
reporter: 'CHECKSTYLE']]]])
}
Simplified configuration example:
if (env.CHANGE_ID) {
step([$class: 'ViolationsToBitbucketServerRecorder',
config: [repositoryConfig : scm,
pullRequestId : env.CHANGE_ID,
commentOnlyChangedContent : false,
commentOnlyChangedContentContext : 0,
createCommentWithAllSingleFileComments: false,
createSingleFileComments : true,
violationConfigs : [[pattern : '.*/checkstyle-result\\.xml$',
reporter: 'CHECKSTYLE']]]])
}
from violation-comments-to-stash-plugin.
Are you sure scm has these values? And if it does, cant you do something like this?
projectKey : env.repositoryConfig.projectKey,
from violation-comments-to-stash-plugin.
Yes, I can simply use: checkout scm
to checkout repository.
Method scm.getKey()
return full repository url.
There is no any environment variables containing project key or repository name.
from violation-comments-to-stash-plugin.
Perhaps if you use https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket and let it provide these variables for you? Then I think you can do:
projectKey : env.PULL_REQUEST_TO_REPO_PROJECT_KEY,
If you parameterize the job with a String parameter like PULL_REQUEST_TO_REPO_PROJECT_KEY
from violation-comments-to-stash-plugin.
Right now I'm using Bitbucket Branch Source Plugin with Post Webhooks for Bitbucket. Direct usage of scm variable will be most reasonable.
from violation-comments-to-stash-plugin.
Perhaps you can get the project key from getRepoOwner and repository from getRepository. But I'm just guessing here =)
from violation-comments-to-stash-plugin.
I'm not sure if I can access this methods from pipeline groovy script.
from violation-comments-to-stash-plugin.
I'd also appreciate this feature.
from violation-comments-to-stash-plugin.
Definitely possible to get the ID and even more: https://github.com/jenkinsci/office-365-connector-plugin/blob/53f1823060c4a7aba72294a08c0efba6751664d5/src/main/java/jenkins/plugins/office365connector/ActionableBuilder.java#L59-L89
Here you get the full URL so ya to the PR even
String urlString = oma.getObjectUrl();
from violation-comments-to-stash-plugin.
For me the following pipeline snipped could collect all needed data:
@NonCPS
void publishBuildResults() {
try {
def gitUrl = scmVars.GIT_URL_1
// https://myserver.example.com/bitbucket/scm/SETOOLS/setools-sbs-bitbucket.git
def urlMatcher = gitUrl =~ '^(https?://[^/]*/bitbucket)/scm/([^/]*)/([^/]*).git$'
if (urlMatcher) {
def bitbucketServer = urlMatcher[0][1]
def projectKey = urlMatcher[0][2]
def repoSlug = urlMatcher[0][3]
def changeId = pipeline.env.CHANGE_ID;
def credentialIdTemp = pipeline.scm.getUserRemoteConfigs()[0].credentialsId;
pipeline.ViolationsToBitbucketServer([
bitbucketServerUrl : bitbucketServer,
commentOnlyChangedContent : true,
commentOnlyChangedContentContext : 5,
createCommentWithAllSingleFileComments: false,
createSingleFileComments : true,
maxNumberOfViolations : 99999,
keepOldComments : true,
projectKey : projectKey,
pullRequestId : changeId,
repoSlug : repoSlug,
credentialsId : credentialIdTemp,
commentTemplate : """
**{{violation.severity}}**: {{violation.message}}
*Reporter: {{violation.reporter}}{{#violation.rule}} // Rule: {{violation.rule}}{{/violation.rule}}*
""",
violationConfigs : [
// Many more formats available, check https://github.com/tomasbjerre/violations-lib
[parser: 'SONAR', pattern: '.*/target/sonar/sonar-report.json', reporter: 'SONAR']
]
])
} else {
pipeline.echo("Does not look like a bitbucket server - think about migrating?")
}
} catch (error) {
// do not leak errors but report them.
pipeline.echo("Error during result publish: " + error)
}
}
from violation-comments-to-stash-plugin.
From what I can tell, this is really more the fault of Bitbucket Branch Source Plugin because it doesn't expose the Bitbucket JSON payload data (project, slug, etc.) from the webhook trigger into the pipeline.
from violation-comments-to-stash-plugin.
Related Issues (20)
- "Outdated" comments not deleted HOT 27
- Credentials not found error HOT 17
- NPE since v1.76 HOT 1
- Plugin doesnโt send comments to bitbucket HOT 17
- All violations related to one file in one comment HOT 7
- Recognition of changed lines seems to not work correclty HOT 15
- Escaped single quote characters in comments
- Allow INFO Files changed to include all scanned files HOT 1
- Violation plugin iterates over files not mentioned in report HOT 6
- NPE after deleting comments HOT 2
- Identify that detecting violations from console/stage output is not supported (directly) HOT 7
- To support Code Insights HOT 2
- INFO POST .../pull-requests/3/comments 400 HOT 5
- Add support for client certificate as credentials HOT 1
- Feature: ignore certain folders/paths/globs HOT 4
- Limit logging of files from Violations Lib HOT 5
- When files paths contains spaces in fails to report warnings HOT 1
- Jenkins agents becoming unresponsive during violations run HOT 3
- Report the "indent" level of an issue HOT 6
- warnings lost, or added as general comments HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from violation-comments-to-stash-plugin.