Gerrit review authentication error

250 views
Skip to first unread message

Ali Raza

unread,
Mar 10, 2021, 9:14:32 AM3/10/21
to Jenkins Users
  Hi
I am using the Gerrit trigger plugin with Jenkins which is working fine but along with it i am also using the Gerrit Code Review plugin. I am calling 'gerrit review' command inside my pipeline script but getting an error 'Gerrit Review requires authentication, however there are no credentials defined or are empty'

I am not sure from where the Gerrit review is getting the credentials. On the other hand, the Gerrit trigger plugin is getting triggered and executing the build process but when it reaches the 'gerrit review' command it is having an authentication error.

Luca Milanesio

unread,
Mar 10, 2021, 9:19:15 AM3/10/21
to 'Björn Pedersen' via Jenkins Users, Luca Milanesio

On 10 Mar 2021, at 13:31, Ali Raza <alira...@gmail.com> wrote:

  Hi
I am using the Gerrit trigger plugin with Jenkins which is working fine but along with it i am also using the Gerrit Code Review plugin. I am calling 'gerrit review' command inside my pipeline script but getting an error 'Gerrit Review requires authentication, however there are no credentials defined or are empty'

Have you defined the credentials in the Gerrit SCM connection in the multi-branch pipeline job?
Also remember to use the ‘/a/‘ prefix for the Gerrit SCM URL, otherwise the access won’t be authenticated.

Example:

HTH

Luca.



I am not sure from where the Gerrit review is getting the credentials. On the other hand, the Gerrit trigger plugin is getting triggered and executing the build process but when it reaches the 'gerrit review' command it is having an authentication error.


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/96f09b40-b415-4e18-969f-89d4915bec36n%40googlegroups.com.

Ali Raza

unread,
Mar 10, 2021, 9:35:43 AM3/10/21
to Jenkins Users
Yes, I have added SCM credentials to my pipeline settings. Inside repository URL I also have ''/a/'' prefix. 

Do i need to add SSH keys which I have added to 'gerrit trigger' plugin settings somewhere inside Gerrit server?


Luca Milanesio

unread,
Mar 10, 2021, 9:39:13 AM3/10/21
to 'Björn Pedersen' via Jenkins Users, Luca Milanesio

On 10 Mar 2021, at 14:35, Ali Raza <alira...@gmail.com> wrote:

Yes, I have added SCM credentials to my pipeline settings. Inside repository URL I also have ''/a/'' prefix. 

Cool, and you confirm that the clone works as expected.


Do i need to add SSH keys which I have added to 'gerrit trigger' plugin settings somewhere inside Gerrit server?

Why do you use the Gerrit Trigger plugin? Isn’t this a multi-branch pipeline?

Luca.



On Wednesday, 10 March 2021 at 15:19:15 UTC+1 luca.mi...@gmail.com wrote:

On 10 Mar 2021, at 13:31, Ali Raza <alira...@gmail.com> wrote:

  Hi
I am using the Gerrit trigger plugin with Jenkins which is working fine but along with it i am also using the Gerrit Code Review plugin. I am calling 'gerrit review' command inside my pipeline script but getting an error 'Gerrit Review requires authentication, however there are no credentials defined or are empty'

Have you defined the credentials in the Gerrit SCM connection in the multi-branch pipeline job?
Also remember to use the ‘/a/‘ prefix for the Gerrit SCM URL, otherwise the access won’t be authenticated.

Example:

HTH

Luca.



I am not sure from where the Gerrit review is getting the credentials. On the other hand, the Gerrit trigger plugin is getting triggered and executing the build process but when it reaches the 'gerrit review' command it is having an authentication error.


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/96f09b40-b415-4e18-969f-89d4915bec36n%40googlegroups.com.


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Ali Raza

unread,
Mar 10, 2021, 9:58:47 AM3/10/21
to jenkins...@googlegroups.com, Luca Milanesio
Yes, it is triggering on gerrit code changes and cloning the repository as well but when it is trying to execute ' gerritReview' command. The code inside my pipeline script where i am having problem is gerritReview labels: ['Unit-test': 1]

It is a plain pipeline job not a multibranch pipeline.





--
Regards

Ali Raza Alvi
Software Engineer
Contact No. +46793456480

Luca Milanesio

unread,
Mar 10, 2021, 10:02:29 AM3/10/21
to Ali Raza, Luca Milanesio, jenkins...@googlegroups.com

On 10 Mar 2021, at 14:58, Ali Raza <alira...@gmail.com> wrote:

Yes, it is triggering on gerrit code changes and cloning the repository as well but when it is trying to execute ' gerritReview' command. The code inside my pipeline script where i am having problem is gerritReview labels: ['Unit-test': 1]

It is a plain pipeline job not a multibranch pipeline.

Gotcha, that isn’t really the use-case that the Gerrit Code Review plugin has been designed for.

There are some environment variables that the plugin expects to be set:

As you can see, the list is quite big :-(
All of them are automatically set when you run in a multi-branch pipeline, otherwise you may need to set them manually.

I know that the Gerrit Trigger Plugin sets some of them, but you should cross-check them.

HTH

Luca.

Luca Milanesio

unread,
Mar 10, 2021, 10:13:11 AM3/10/21
to Ali Raza, Luca Milanesio, jenkins...@googlegroups.com

On 10 Mar 2021, at 15:02, Luca Milanesio <luca.mi...@gmail.com> wrote:



On 10 Mar 2021, at 14:58, Ali Raza <alira...@gmail.com> wrote:

Yes, it is triggering on gerrit code changes and cloning the repository as well but when it is trying to execute ' gerritReview' command. The code inside my pipeline script where i am having problem is gerritReview labels: ['Unit-test': 1]

It is a plain pipeline job not a multibranch pipeline.

Gotcha, that isn’t really the use-case that the Gerrit Code Review plugin has been designed for.

There are some environment variables that the plugin expects to be set:

As you can see, the list is quite big :-(
All of them are automatically set when you run in a multi-branch pipeline, otherwise you may need to set them manually.

One question: what type of Git SCM source URL are you using?
Git/HTTP or Git/SSH?

Can you share the settings?

Luca.

Ali Raza

unread,
Mar 10, 2021, 11:12:50 AM3/10/21
to Jenkins Users
One thing I forgot to mention is that same job is working on another server with the same setting. When we migrated it to a new server it start having the problem. So all of the environment variables and script were working on the previous server. We have many other jobs which are not using multibranch pipelines that is why it will be bit challenging to move them on multibranch pipeline. 

I am using git/https as a SCM source(https://GERRIT_BASE_URL/a/PROJECT) and passing the username and password inside the credentials.

gerrit.jpg 

Luca Milanesio

unread,
Mar 10, 2021, 11:23:20 AM3/10/21
to 'Björn Pedersen' via Jenkins Users, Luca Milanesio

On 10 Mar 2021, at 16:12, Ali Raza <alira...@gmail.com> wrote:

One thing I forgot to mention is that same job is working on another server with the same setting. When we migrated it to a new server it start having the problem. So all of the environment variables and script were working on the previous server. We have many other jobs which are not using multibranch pipelines that is why it will be bit challenging to move them on multibranch pipeline. 

I am using git/https as a SCM source(https://GERRIT_BASE_URL/a/PROJECT) and passing the username and password inside the credentials.

I believe the Gerrit Code Review plugin assumes the SCM source is a Gerrit SCM (not Git SCM) and it may fail to access the credentials there.

Luca.

Ali Raza

unread,
Mar 10, 2021, 12:19:28 PM3/10/21
to Jenkins Users
I am not getting gerrit option in the dropdown but surprisingly it able to clone the code from repo and jenkins script from another repo both hosted on gerrit. It even is able to build the docker using the jenkins build script.

gerrit.jpg



Luca Milanesio

unread,
Mar 10, 2021, 12:22:17 PM3/10/21
to 'Björn Pedersen' via Jenkins Users, Luca Milanesio

On 10 Mar 2021, at 17:19, Ali Raza <alira...@gmail.com> wrote:

I am not getting gerrit option in the dropdown but surprisingly it able to clone the code from repo and jenkins script from another repo both hosted on gerrit. It even is able to build the docker using the jenkins build script.

That is weird: have you installed the “Gerrit Code Review” plugin v0.4.4?

If yes, it should provide a Gerrit SCM and it should be visible in the list of options.

Luca.

Ali Raza

unread,
Mar 10, 2021, 12:29:02 PM3/10/21
to jenkins...@googlegroups.com, Luca Milanesio
Yes, I am using the  “G errit Code Review” plugin v0.4.4.

gerrit.jpg

Ali Raza

unread,
Mar 11, 2021, 9:56:35 AM3/11/21
to jenkins...@googlegroups.com, Luca Milanesio
Can it be the problem with the port which the gerrit trigger plugin for ssh?

jimsearle

unread,
Feb 2, 2022, 12:32:33 PM2/2/22
to Jenkins Users
Hi,

Was this ever resolved?  I am also not seeing Gerrit as an option in the Pipeline -> SCM list
Reply all
Reply to author
Forward
0 new messages