{"action":"created","issue":{"url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/78","labels_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/78/comments","events_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/78/events","html_url":"https://github.com/jenkinsci/stashnotifier-plugin/issues/78","id":119055965,"number":78,"title":"Failed to notify Stash for commit, ({\"errors\":[{\"context\":null,\"message\":\"Authentication failed. Please check your credentials and try again.\",\"exceptionName\":null}]})","user":{"login":"anbeque","id":1849277,"avatar_url":"https://avatars.githubusercontent.com/u/1849277?v=3","gravatar_id":"","url":"https://api.github.com/users/anbeque","html_url":"https://github.com/anbeque","followers_url":"https://api.github.com/users/anbeque/followers","following_url":"https://api.github.com/users/anbeque/following{/other_user}","gists_url":"https://api.github.com/users/anbeque/gists{/gist_id}","starred_url":"https://api.github.com/users/anbeque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anbeque/subscriptions","organizations_url":"https://api.github.com/users/anbeque/orgs","repos_url":"https://api.github.com/users/anbeque/repos","events_url":"https://api.github.com/users/anbeque/events{/privacy}","received_events_url":"https://api.github.com/users/anbeque/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/labels/incomplete%20issue","name":"incomplete issue","color":"006b75"},{"url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/labels/potential%20bug","name":"potential bug","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-11-26T14:35:44Z","updated_at":"2016-01-12T23:10:39Z","closed_at":null,"body":"Hi,\r\n\r\nStash v3.11.3\r\nJenkins 1.529\r\nStash Notifier plugin : tested with both 1.5 and 1.9.0.\r\n\r\nThis is the error, same thing with v1.5 and v1.9.0 of the Stash Notifier plugin:\r\n\r\nFailed to notify Stash for commit xxxx ({\"errors\":[{\"context\":null,\"message\":\"Authentication failed. Please check your credentials and try again.\",\"exceptionName\":null}]}).\r\n\r\nWe are not specifying any value in these fields:\r\n\r\nIgnore unverified SSL certificates,\r\nKeep repeated builds in Stash\r\nOverride project key\r\nPrepend parent project name to key\r\nDisable INPROGRESS notification\r\n\r\nIt stopped working after upgrading our Stash server from v2.10.2 to v3.11.3. We tried upgrading the Stash Notifier plugin to the latest version and using the Credentials plugin to do the authenticate, but still getting the same issue.\r\n\r\nWould you have any idea about why it does fail? May I'm missing something at config level. Any advise is welcome.\r\n\r\nThanks,\r\nAngela.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/comments/171092406","html_url":"https://github.com/jenkinsci/stashnotifier-plugin/issues/78#issuecomment-171092406","issue_url":"https://api.github.com/repos/jenkinsci/stashnotifier-plugin/issues/78","id":171092406,"user":{"login":"stevengssns","id":1157521,"avatar_url":"https://avatars.githubusercontent.com/u/1157521?v=3","gravatar_id":"","url":"https://api.github.com/users/stevengssns","html_url":"https://github.com/stevengssns","followers_url":"https://api.github.com/users/stevengssns/followers","following_url":"https://api.github.com/users/stevengssns/following{/other_user}","gists_url":"https://api.github.com/users/stevengssns/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengssns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengssns/subscriptions","organizations_url":"https://api.github.com/users/stevengssns/orgs","repos_url":"https://api.github.com/users/stevengssns/repos","events_url":"https://api.github.com/users/stevengssns/events{/privacy}","received_events_url":"https://api.github.com/users/stevengssns/received_events","type":"User","site_admin":false},"created_at":"2016-01-12T23:10:39Z","updated_at":"2016-01-12T23:10:39Z","body":"@scaytrase The issue seems to be related indeed. After doing some testing of my preliminary fix, I hit this issue (which turns out to be the \"other issue\" I was talking about in #86 ).\r\n\r\nIt took me some browsing through the code, but I think I might have figured out the issue here. In any case it fixed the issue in my setup.\r\n\r\nThe problem seems to occur on this line (mentioned above somewhere already), when the request is being created:\r\n\r\nCredentials credentials = CredentialsMatchers.firstOrNull(CredentialsProvider.lookupCredentials(CertificateCredentials.class,\r\n                Jenkins.getInstance(), ACL.SYSTEM), CredentialsMatchers.withId(credentialsId)); \r\n\r\nThe lookupCredentials method seems to only find the top level credentials, which might nog be so surprising when calling it with Jenkins.getInstance(). I figure this represents the top level Item (of jenkins instance). When replace it with build.getProject() (after adding the \"build\" parameter to the method signature), I get the correct credentials. I actually get an ordered list of all the visible credentials in the project hierarchy, which is exactly what I would expect. \r\n\r\nI'll try to update my open PR tomorrow to include this possible fix. And maybe some additional cleanup if I'm confident enough."}}