-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possibility to use scm variable in multibranch pipeline #28
Comments
Do you have an example of where it does not work? |
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']]]])
} |
Are you sure scm has these values? And if it does, cant you do something like this?
|
Yes, I can simply use: There is no any environment variables containing project key or repository name. |
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:
If you parameterize the job with a String parameter like PULL_REQUEST_TO_REPO_PROJECT_KEY |
Right now I'm using Bitbucket Branch Source Plugin with Post Webhooks for Bitbucket. Direct usage of scm variable will be most reasonable. |
Perhaps you can get the project key from getRepoOwner and repository from getRepository. But I'm just guessing here =) |
I'm not sure if I can access this methods from pipeline groovy script. |
I'd also appreciate this feature. |
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 |
For me the following pipeline snipped could collect all needed data:
|
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. |
It will be nice if we can use scm variable in multibranch pipeline jenkinsfile.
The text was updated successfully, but these errors were encountered: