[JIRA] (JENKINS-50459) 401 when trying to update the build status in gitea

309 views
Skip to first unread message

james.strachan@gmail.com (JIRA)

unread,
Mar 28, 2018, 9:48:02 AM3/28/18
to jenkinsc...@googlegroups.com
James Strachan created an issue
 
Jenkins / Bug JENKINS-50459
401 when trying to update the build status in gitea
Issue Type: Bug Bug
Assignee: Unassigned
Components: gitea-plugin
Created: 2018-03-28 13:47
Environment: Jenkins X with the gitea addon enabled on GKE
Priority: Minor Minor
Reporter: James Strachan

I can use Jenkins X with gitea and the gitea-plugin to create repos & setup MultiBranchProjects for PRs/master and webhooks and all that are working great. 
 
However each pipeilne build fails to update the build status. Here's the exceptions that are generated at the beginning and end of a pipeline run. Its a little odd its a 401 as there's 1 credential used for querying the MBP branches, reading repos from gitea and doing commits/issues/PRs etc - so the credential is fine and the same credential is used in the Jenkins server config + the MBp
 
Here's a sample stack trace at the start...
[Gitea] Notifying branch build status: PENDING Build started... ERROR: Could not send notifications org.jenkinsci.plugin.gitea.client.api.GiteaHttpStatusException: HTTP 401/Unauthorized {"context":"test-user/environment-jstrachan-test8-staging/master","description":"Build started...","state":"pending","status":"pending","target_url":"http://jenkins.jx.35.197.207.229.nip.io/job/test-user/job/environment-jstrachan-test8-staging/job/master/2/display/redirect"} at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.post(DefaultGiteaConnection.java:911) at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.createCommitStatus(DefaultGiteaConnection.java:550) at org.jenkinsci.plugin.gitea.GiteaNotifier.sendNotifications(GiteaNotifier.java:144) at org.jenkinsci.plugin.gitea.GiteaNotifier.access$200(GiteaNotifier.java:66) at org.jenkinsci.plugin.gitea.GiteaNotifier$JobCheckOutListener.onCheckout(GiteaNotifier.java:277) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:127) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85) at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47) at hudson.security.ACL.impersonate(ACL.java:290) at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)  
 
then at the end:
[Gitea] Notifying branch build status: SUCCESS This commit looks good ERROR: Could not send notifications org.jenkinsci.plugin.gitea.client.api.GiteaHttpStatusException: HTTP 401/Unauthorized {"context":"test-user/environment-jstrachan-test8-staging/master","description":"This commit looks good","state":"success","status":"success","target_url":"http://jenkins.jx.35.197.207.229.nip.io/job/test-user/job/environment-jstrachan-test8-staging/job/master/2/display/redirect"} at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.post(DefaultGiteaConnection.java:911) at org.jenkinsci.plugin.gitea.client.impl.DefaultGiteaConnection.createCommitStatus(DefaultGiteaConnection.java:550) at org.jenkinsci.plugin.gitea.GiteaNotifier.sendNotifications(GiteaNotifier.java:144) at org.jenkinsci.plugin.gitea.GiteaNotifier.access$200(GiteaNotifier.java:66) at org.jenkinsci.plugin.gitea.GiteaNotifier$JobCompletedListener.onCompleted(GiteaNotifier.java:297) at hudson.model.listeners.RunListener.fireCompleted(RunListener.java:211) at org.jenkinsci.plugins.workflow.job.WorkflowRun.finish(WorkflowRun.java:688) at org.jenkinsci.plugins.workflow.job.WorkflowRun.access$1400(WorkflowRun.java:143) at org.jenkinsci.plugins.workflow.job.WorkflowRun$GraphL.onNewHead(WorkflowRun.java:1006) at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.notifyListeners(CpsFlowExecution.java:1368) at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$3.run(CpsThreadGroup.java:412) at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.run(CpsVmExecutorService.java:35) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Finished: SUCCESS

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

james.strachan@gmail.com (JIRA)

unread,
Apr 18, 2018, 7:47:02 AM4/18/18
to jenkinsc...@googlegroups.com
James Strachan commented on Bug JENKINS-50459
 
Re: 401 when trying to update the build status in gitea

this could maybe be related to the kind of Credential it is and its format/data - we hit a similar issue with Bitbucket on Jenkins X: https://github.com/jenkins-x/jx/issues/665

james.strachan@gmail.com (JIRA)

unread,
Apr 21, 2018, 8:12:02 AM4/21/18
to jenkinsc...@googlegroups.com

Turns out it’s not related! Tried using a manually created regular username/password - plus a Gitea Personal Access Token credential- they all fail with a 401

mneale@cloudbees.com (JIRA)

unread,
Jun 17, 2018, 11:32:02 PM6/17/18
to jenkinsc...@googlegroups.com

James Strachan I was able to reproduce it - but by incorrectly using a personal access token as a "password" type of credential.This resulted in 401s. 

Unlike in github's case, the personal access token for gitea can't just be dropped in place of the password (I think). 

When I set it up as the correct credential type - it did work for me and set the status correctly. 

 

https://github.com/jenkinsci/gitea-plugin/blob/master/src/main/java/org/jenkinsci/plugin/gitea/credentials/PersonalAccessToken.java

https://github.com/jenkinsci/gitea-plugin/blob/master/src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection.java#L826 (see how it uses the token header in the token case, but not username/password). 

 

Anyway - will discuss on this: https://github.com/jenkins-x/jx/issues/432#issuecomment-397531961 as JIRA commenting is annoying me (and can confirm if that was the issue blocking things)

mneale@cloudbees.com (JIRA)

unread,
Jun 17, 2018, 11:52:02 PM6/17/18
to jenkinsc...@googlegroups.com
Michael Neale edited a comment on Bug JENKINS-50459
[~jstrachan] I was able to reproduce it - but by incorrectly using a personal access token as a "password" type of credential.This resulted in 401s. 


Unlike in github's case, the personal access token for gitea can't just be dropped in place of the password (I think). 

When I set it up as the correct credential type - it did work for me and set the status correctly. 

 

[https://github.com/jenkinsci/gitea-plugin/blob/master/src/main/java/org/jenkinsci/plugin/gitea/credentials/PersonalAccessToken.java]

[https://github.com/jenkinsci/gitea-plugin/blob/master/src/main/java/org/jenkinsci/plugin/gitea/client/impl/DefaultGiteaConnection.java#L826] (see how it uses the token header in the token case, but not username/password)


 

Anyway - will discuss on this: [https://github.com/jenkins-x/jx/issues/432#issuecomment-397531961] as JIRA commenting is annoying me (and can confirm if that was the issue blocking things)
- as I don't think this is a bug if it is what I think it is. 

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:34:02 AM8/3/18
to jenkinsc...@googlegroups.com
Stephen Connolly updated an issue
 
Change By: Stephen Connolly
Attachment: Screen Shot 2018-08-03 at 13.27.37.png
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:35:01 AM8/3/18
to jenkinsc...@googlegroups.com
Stephen Connolly updated an issue
Change By: Stephen Connolly
Attachment: Screen Shot 2018-08-03 at 13.27.48.png

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:36:01 AM8/3/18
to jenkinsc...@googlegroups.com
Stephen Connolly updated an issue
Change By: Stephen Connolly
Attachment: Screen Shot 2018-08-03 at 13.35.16.png

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:36:02 AM8/3/18
to jenkinsc...@googlegroups.com

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:37:02 AM8/3/18
to jenkinsc...@googlegroups.com
Stephen Connolly updated an issue
Change By: Stephen Connolly
Attachment: Screen Shot 2018-08-03 at 13.36.36.png

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:38:02 AM8/3/18
to jenkinsc...@googlegroups.com
Stephen Connolly updated an issue
Change By: Stephen Connolly
Attachment: Screen Shot 2018-08-03 at 13.36.15.png

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:39:01 AM8/3/18
to jenkinsc...@googlegroups.com
Stephen Connolly commented on Bug JENKINS-50459
 
Re: 401 when trying to update the build status in gitea

So, does your user have the correct permissions to post status updates?

Here is Jenkins building when using my api token:

Here is Jenkins building when using my user/pass:

Here is Jenkins building when using the user bob who has Read permission only on the repo:


Now if we give bob Write permissions on the repo:


So it seems like the issue here is that you are getting an ugly error message... though the message is completely accurate, could not send notification because unauthorized.

Seems like everything is functioning as designed

stephen.alan.connolly@gmail.com (JIRA)

unread,
Aug 3, 2018, 8:40:02 AM8/3/18
to jenkinsc...@googlegroups.com
Stephen Connolly resolved as Not A Defect
 

If we want an issue to make the error message prettier, that's fine, but the functionality works and the error message is reporting the exact issue correctly from what I can see

Change By: Stephen Connolly
Status: Open Resolved
Resolution: Not A Defect

james.strachan@gmail.com (JIRA)

unread,
Sep 6, 2018, 3:00:04 AM9/6/18
to jenkinsc...@googlegroups.com
James Strachan commented on Bug JENKINS-50459
 
Re: 401 when trying to update the build status in gitea

Stephen Connolly I wonder in your tests was that a regular UserPasswordCredential being used under the covers? I'm wondering if this is an effect of using the kubernetes credentials provider plugin which creates the credentials and is only aware of the standard Credential implementation classes right now

This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

james.strachan@gmail.com (JIRA)

unread,
Sep 6, 2018, 3:00:04 AM9/6/18
to jenkinsc...@googlegroups.com
James Strachan edited a comment on Bug JENKINS-50459
[~stephenconnolly] I wonder in your tests was that a regular UserPasswordCredential class being used under the covers? I'm wondering if this is an effect of using the kubernetes credentials provider plugin which creates the credentials and is only aware of the standard Credential implementation classes right now

franag1987@gmail.com (JIRA)

unread,
Oct 5, 2018, 6:47:03 AM10/5/18
to jenkinsc...@googlegroups.com
Fran Aguiar updated an issue
 
Change By: Fran Aguiar
Attachment: plugin.png
Attachment: actions.png

franag1987@gmail.com (JIRA)

unread,
Oct 5, 2018, 6:49:02 AM10/5/18
to jenkinsc...@googlegroups.com

franag1987@gmail.com (JIRA)

unread,
Oct 5, 2018, 6:49:03 AM10/5/18
to jenkinsc...@googlegroups.com

franag1987@gmail.com (JIRA)

unread,
Oct 5, 2018, 6:49:03 AM10/5/18
to jenkinsc...@googlegroups.com
Fran Aguiar commented on Bug JENKINS-50459
 
Re: 401 when trying to update the build status in gitea

How can I use this feature?
I already have installed gitea-plugin, but in my build steps I don't see nothing related to this.

See captures, there is github, but not gitea... What I'm missing?

 

 

Any idea?

Reply all
Reply to author
Forward
0 new messages