Skip to content
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

Plugin doesn’t send comments to bitbucket #58

Closed
lelik9 opened this issue Sep 17, 2018 · 17 comments
Closed

Plugin doesn’t send comments to bitbucket #58

lelik9 opened this issue Sep 17, 2018 · 17 comments

Comments

@lelik9
Copy link

lelik9 commented Sep 17, 2018

I can't realize why it doesn't publish comments into bitbucket.

Here is a part of pipeline:

ViolationsToBitbucketServer([bitbucketServerUrl: 'https://bitbucket.astrazeneca.net', 
                                               commentTemplate: '''**Reporter**: {{violation.reporter}}{{#violation.rule}}

                                               **Rule**: {{violation.rule}}{{/violation.rule}}
                                               **Severity**: {{violation.severity}}
                                               **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}

                                               **Source**: {{violation.source}}{{/violation.source}}

                                               {{violation.message}}''', 
                                               createCommentWithAllSingleFileComments: true, 
                                               credentialsId: '80981402-7ed6-490d-96ee-1a7dcaab9921',
                                               keepOldComments: true, minSeverity: 'WARN', 
                                               projectKey: 'SCP', 
                                               pullRequestId: "$params.pullrequest", 
                                               repoSlug: 'scpcore', 
                                               violationConfigs: [[parser: 'YAMLLINT', pattern: '.*lint_result*\\.txt$', reporter: 'yamllint']]
                                               ])

And here what I see in jenkins console:

2018-09-17 16:13:25 ---
2018-09-17 16:13:25 --- Jenkins Violation Comments to Bitbucket Server ---
2018-09-17 16:13:25 ---
2018-09-17 16:13:25 bitbucketServerUrl: https://bitbucket.astrazeneca.net
2018-09-17 16:13:25 projectKey: SCP
2018-09-17 16:13:25 repoSlug: scpcore
2018-09-17 16:13:25 pullRequestId: 967
2018-09-17 16:13:25 credentialsId: true
2018-09-17 16:13:25 createSingleFileComments: false
2018-09-17 16:13:25 createSingleFileCommentsTasks: false
2018-09-17 16:13:25 createCommentWithAllSingleFileComments: true
2018-09-17 16:13:25 commentOnlyChangedContent: false
2018-09-17 16:13:25 commentOnlyChangedContentContext: 0
2018-09-17 16:13:25 minSeverity: WARN
2018-09-17 16:13:25 keepOldComments: true
2018-09-17 16:13:25 commentTemplate: **Reporter**: {{violation.reporter}}{{#violation.rule}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Rule**: {{violation.rule}}{{/violation.rule}}
2018-09-17 16:13:25                                                 **Severity**: {{violation.severity}}
2018-09-17 16:13:25                                                 **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Source**: {{violation.source}}{{/violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 {{violation.message}}
2018-09-17 16:13:25 yamllint with pattern .*lint_result*\.txt$
2018-09-17 16:13:25 Pull request: 967
2018-09-17 16:13:25 Workspace: /home/easybuild-jenkins/workspace/Development/aleksei_test/ansible_lint/scpcore
2018-09-17 16:13:25 Found 13 violations from ViolationConfig [pattern=.*lint_result*\.txt$, reporter=yamllint, parser=YAMLLINT].
2018-09-17 16:13:25 PR: SCP/scpcore/967 on https://bitbucket.astrazeneca.net

Jenkins log is empty, no errors during a build.

What I do wrong?

Best regards,
Aleksei Philippov

Hello Tomas,

Could you please help me with this plugin. I can't realize why it doesn't publish comments into bitbucket.

Here is a part of pipeline:

ViolationsToBitbucketServer([bitbucketServerUrl: 'https://bitbucket.astrazeneca.net', 
                                               commentTemplate: '''**Reporter**: {{violation.reporter}}{{#violation.rule}}

                                               **Rule**: {{violation.rule}}{{/violation.rule}}
                                               **Severity**: {{violation.severity}}
                                               **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}

                                               **Source**: {{violation.source}}{{/violation.source}}

                                               {{violation.message}}''', 
                                               createCommentWithAllSingleFileComments: true, 
                                               credentialsId: '80981402-7ed6-490d-96ee-1a7dcaab9921',
                                               keepOldComments: true, minSeverity: 'WARN', 
                                               projectKey: 'SCP', 
                                               pullRequestId: "$params.pullrequest", 
                                               repoSlug: 'scpcore', 
                                               violationConfigs: [[parser: 'YAMLLINT', pattern: '.*lint_result*\\.txt$', reporter: 'yamllint']]
                                               ])

And here what I see in jenkins console:

2018-09-17 16:13:25 ---
2018-09-17 16:13:25 --- Jenkins Violation Comments to Bitbucket Server ---
2018-09-17 16:13:25 ---
2018-09-17 16:13:25 bitbucketServerUrl: https://bitbucket.astrazeneca.net
2018-09-17 16:13:25 projectKey: SCP
2018-09-17 16:13:25 repoSlug: scpcore
2018-09-17 16:13:25 pullRequestId: 967
2018-09-17 16:13:25 credentialsId: true
2018-09-17 16:13:25 createSingleFileComments: false
2018-09-17 16:13:25 createSingleFileCommentsTasks: false
2018-09-17 16:13:25 createCommentWithAllSingleFileComments: true
2018-09-17 16:13:25 commentOnlyChangedContent: false
2018-09-17 16:13:25 commentOnlyChangedContentContext: 0
2018-09-17 16:13:25 minSeverity: WARN
2018-09-17 16:13:25 keepOldComments: true
2018-09-17 16:13:25 commentTemplate: **Reporter**: {{violation.reporter}}{{#violation.rule}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Rule**: {{violation.rule}}{{/violation.rule}}
2018-09-17 16:13:25                                                 **Severity**: {{violation.severity}}
2018-09-17 16:13:25                                                 **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Source**: {{violation.source}}{{/violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 {{violation.message}}
2018-09-17 16:13:25 yamllint with pattern .*lint_result*\.txt$
2018-09-17 16:13:25 Pull request: 967
2018-09-17 16:13:25 Workspace: /home/easybuild-jenkins/workspace/Development/aleksei_test/ansible_lint/scpcore
2018-09-17 16:13:25 Found 13 violations from ViolationConfig [pattern=.*lint_result*\.txt$, reporter=yamllint, parser=YAMLLINT].
2018-09-17 16:13:25 PR: SCP/scpcore/967 on https://bitbucket.astrazeneca.net

Jenkins log is empty, no errors during a build.

What I do wrong?

@tomasbjerre
Copy link
Contributor

Are you sure that the lint_result.txt contains violations from the files that were changed in the pull request?
Are you sure they are of severity WARN or ERROR?

@lelik9
Copy link
Author

lelik9 commented Sep 17, 2018

Yes. Files mentioned in the lint_result.txt is present in a PR. And yamllint produce only error and warning severity.
Is it make sense absolute/relative path of files in a report?

@tomasbjerre
Copy link
Contributor

Yes relative paths msy be the problem.

See also: tomasbjerre/violations-lib#40

@lelik9
Copy link
Author

lelik9 commented Sep 17, 2018

Removed all relative path from the report, but this didn't help me.
Also I've checked what returned /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/diff for my PR.
It returns

"diffs":[{"source":null,"destination":{"components":["molecule-default","create.yml"],"parent":"molecule-default","name":"create.yml","extension":"yml","toString":"molecule-default/create.yml"},"hunks":[{"sourceLine":0,"sourceSpan":0,"destinationLine":1,"destinationSpan":134,"segments":[{"type":"ADDED","lines":[{"source":0,"destination":1,"line":"---","truncated":false},{"source":0,"destination":2,"line":"- name: Create","truncated":false},...

I've looked quickly into your code and as I understand it means that file is changed and comment will be send. Am I correct?
And in my report file present this file:

molecule-default/create.yml:6:89: [error] line too long (116 > 88 characters) (line-length)

tomasbjerre added a commit that referenced this issue Sep 18, 2018
@tomasbjerre
Copy link
Contributor

Releasing 1.82 now. It should give you some helpful information in the build log.

@lelik9
Copy link
Author

lelik9 commented Sep 18, 2018

Thanks for this release, it's very useful output information. I found out that plugin doesn't see any changed files. Could you please describe how does plugin detect which files were already changed or in what parts of the code I need to look, to understand how it works?

@tomasbjerre
Copy link
Contributor

That would be here in getFiles(): https://github.com/tomasbjerre/violation-comments-to-bitbucket-server-lib/blob/master/src/main/java/se/bjurr/violations/comments/bitbucketserver/lib/BitbucketServerCommentsProvider.java#L115

And that looks like this returns no files:
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/changes?limit=999999

What does it return?

@lelik9
Copy link
Author

lelik9 commented Sep 18, 2018

It returns


{  
   "fromHash":"8d2fa6f0f6c5df46d3f63ef71df6f2a2af42ff55",
   "toHash":"cb2cdb92cc349b930082c796202a2680422ee9b8",
   "properties":{  
      "changeScope":"ALL"
   },
   "values":[  
      {  
         "contentId":"b1643800f179e7c28213b17f1bfc5b02ec96d13a",
         "fromContentId":"0000000000000000000000000000000000000000",
         "path":{  
            "components":[  
               "molecule-default",
               "create.yml"
            ],
            "parent":"molecule-default",
            "name":"create.yml",
            "extension":"yml",
            "toString":"molecule-default/create.yml"
         },
         "executable":false,
         "percentUnchanged":-1,
         "type":"ADD",
         "nodeType":"FILE",
         "links":{  
            "self":[  
               null
            ]
         },
         "properties":{  
            "gitChangeType":"ADD"
         }
      },...

tomasbjerre added a commit that referenced this issue Sep 18, 2018
@tomasbjerre
Copy link
Contributor

I'm releasing 1.83 now with some more logging.

@lelik9
Copy link
Author

lelik9 commented Sep 19, 2018

Thank you. The problem was in that the plugin didn't get a proper response.
I recieved DNS error:


2018-09-19 08:54:34 <html><head><title>502 Bad Gateway</title></head>
2018-09-19 08:54:34 <body><h1>DNS error</h1>
2018-09-19 08:54:34 <p>DNS error (the host name of the page you are looking for does not exist)<br><br>Please check that the host name has been spelled correctly.<br></p>

And this is quite strange, because before executing this step I do a request to the same DNS name with HTTPrequest plugin and get proper response.

@tomasbjerre
Copy link
Contributor

Ok. What does the build log look like now? Is this problem obvious for anyone looking at the build log?

Do you still think this might be a problem with the plugin?

@lelik9
Copy link
Author

lelik9 commented Sep 19, 2018

Log looks awesome, currently it is really easier to investigate a problem. I think might be good for each request write to the log: request URL, headers, response code and response body. It's very useful info for debugging.
Unfortunately I think a problem might be in the plugin, because I used HTTP request in the same job and step to request the same URL, and got proper response.

@tomasbjerre
Copy link
Contributor

Are you using nodes? Or running everything on master node? And are you making that request on same node as the plugin is running on?

@lelik9
Copy link
Author

lelik9 commented Sep 19, 2018

I use separate build node, but all steps run on the same node

@tomasbjerre
Copy link
Contributor

One guess is that it could be that the plugin is using a proxy. If you have a proxy configured in Jenkins the plugin will pick it up and use it.

There is no logging saying that the proxy is used. But there is logging saying that is is not used. So if you don't see any Not using proxy in the build log, the plugin is using a proxy.

@lelik9
Copy link
Author

lelik9 commented Sep 19, 2018

Yep, that was a problem! Thank you for your help!
Could you please add in the log information about proxy if it used.

@tomasbjerre
Copy link
Contributor

Yes adding that!

tomasbjerre added a commit that referenced this issue Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants