Use withCredentials and httpRequest in Active choice parameter

1,271 views
Skip to first unread message

den...@gmail.com

unread,
Jul 29, 2018, 7:54:20 PM7/29/18
to BioUno Users
Hello there!

I'm trying to get something like this working w/o any luck:
  withCredentials([usernamePassword(credentialsId: 'ecr:eu-west-1:aws-jenkins-prod', passwordVariable: 'PASSWORD', usernameVariable: 'USER')]) {
   
def responseRaw = httpRequest(
      consoleLogResponseBody
: false,
      customHeaders
: [
       
[maskValue: true, name: 'Authorization', value: "Basic " + PASSWORD],
       
[maskValue: false, name: 'Accept', value: 'application/vnd.docker.distribution.manifest.v2+json']
     
],
      contentType
: 'APPLICATION_JSON',
      responseHandle
: 'LEAVE_OPEN',
      httpMode
: 'GET',
      url
: 'https://' + Constants.ECR_REPO + '/v2/myrepo/tags/list?n=1000',
      validResponseCodes
: '200'
   
);

   
def response = responseRaw.content
   
def response_status = responseRaw.status
    responseRaw
.close();
   
   
def responseParsed = new groovy.json.JsonSlurperClassic().parseText(response);
   
return responseParsed['tags'].sort().reverse();
 
}

This code works just fine in my pipeline both inline and as function from default shared library configured in my Jenkins.
But for Active Choice Parameter I always getting fall back value.

In plain English I'm trying to get list of tags from private docker reposity so that operator would be able to pick image of his interest

Any advice on how to make it working?

Many thanks in advance!

Bruno P. Kinoshita

unread,
Jul 29, 2018, 8:31:58 PM7/29/18
to biouno...@googlegroups.com
Hi,

I haven't used much of Active Choices + Pipelines. Normally the problem when a user is trying to use both together is related to the DOM not being present.

But in your case it looks like when you run that groovy with pipeline plugin, the classpath is different, and contains the reference for the other plug-ins.

Could you create a JIRA ticket for that, please? With the component for this plug-in. It should automatically be assigned to me, and then I will take a look once I start a new cycle for the plugin development

Thanks!
Bruno



From: "den...@gmail.com" <den...@gmail.com>
To: BioUno Users <biouno...@googlegroups.com>
Sent: Monday, 30 July 2018 11:54 AM
Subject: Use withCredentials and httpRequest in Active choice parameter

--
You received this message because you are subscribed to the Google Groups "BioUno Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biouno-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Denis Boulas

unread,
Jul 30, 2018, 4:30:30 AM7/30/18
to biouno...@googlegroups.com
Probably I wasn't clear... I use it in pipeline project BUT Active parameter was added as a standard configuration to a jenkins job (not in the pipeline itself). But groovy code I've stated above doesn't work in active parameter

To unsubscribe from this group and stop receiving emails from it, send an email to biouno-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

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

For more options, visit https://groups.google.com/d/optout.



--
Best regards,
Denis Boulas

Bruno P. Kinoshita

unread,
Jul 30, 2018, 4:40:32 AM7/30/18
to biouno...@googlegroups.com
I think that's more or less what I understood too. Sorry if my reply wasn't clear.

Again, the classpath set up by the active choices plugin, might not be the same as the one set by Jenkins and/or the pipeline plugin et al. Hence, we need a ticket to investigate it.

Might be that there's some method/class that we need to use to tell that we want to allow Groovy scripts that work well with pipeline (and possibly other plugins) to work as similar as possible with active choices parameters.

Hope that makes sense.

Bruno



From: Denis Boulas <den...@gmail.com>
To: biouno...@googlegroups.com
Sent: Monday, 30 July 2018 8:30 PM
Subject: Re: Use withCredentials and httpRequest in Active choice parameter

Probably I wasn't clear... I use it in pipeline project BUT Active parameter was added as a standard configuration to a jenkins job (not in the pipeline itself). But groovy code I've stated above doesn't work in active parameter
2018-07-30 3:31 GMT+03:00 'Bruno P. Kinoshita' via BioUno Users <biouno...@googlegroups.com>:
Hi,

I haven't used much of Active Choices + Pipelines. Normally the problem when a user is trying to use both together is related to the DOM not being present.

But in your case it looks like when you run that groovy with pipeline plugin, the classpath is different, and contains the reference for the other plug-ins.

Could you create a JIRA ticket for that, please? With the component for this plug-in. It should automatically be assigned to me, and then I will take a look once I start a new cycle for the plugin development

Thanks!
Bruno



From: "den...@gmail.com" <den...@gmail.com>
To: BioUno Users <biouno...@googlegroups.com >
Sent: Monday, 30 July 2018 11:54 AM
Subject: Use withCredentials and httpRequest in Active choice parameter
Hello there!

I'm trying to get something like this working w/o any luck:
  withCredentials([usernamePassw ord(credentialsId: 'ecr:eu-west-1:aws-jenkins- prod', passwordVariable: 'PASSWORD', usernameVariable: 'USER')]) {

--
Best regards,
Denis Boulas
--
You received this message because you are subscribed to the Google Groups "BioUno Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biouno-users...@googlegroups.com.

Dev

unread,
Nov 12, 2019, 4:19:30 PM11/12/19
to BioUno Users
Hi Den, Bruno,
Facing a similar issue, was this resolved or any workarounds/inputs ? Thank you

Bruno P. Kinoshita

unread,
Nov 14, 2019, 9:02:34 PM11/14/19
to BioUno Users
Hi,

The plugin - as far as I know - never worked with pipelines. It relies on the HTML forms to fetch the values of other parameters. There is an open issue with some comments and requirements, but there hasn't been a fix for that yet.

It should work if using a common freestyle job.

Bruno

On Wednesday, 13 November 2019, 10:19:32 am NZDT, Dev <devsecops...@gmail.com> wrote:


Hi Den, Bruno,
Facing a similar issue, was this resolved or any workarounds/inputs ? Thank you

On Monday, 30 July 2018 05:24:20 UTC+5:30, den...@gmail.com wrote:
Hello there!

I'm trying to get something like this working w/o any luck:
  withCredentials([usernamePassw ord(credentialsId: 'ecr:eu-west-1:aws-jenkins- prod', passwordVariable: 'PASSWORD', usernameVariable: 'USER')]) {

   
def responseRaw = httpRequest(
      consoleLogResponseBody
: false,
      customHeaders
: [
       
[maskValue: true, name: 'Authorization', value: "Basic " + PASSWORD],
       
[maskValue: false, name: 'Accept', value: 'application/vnd.docker. distribution.manifest.v2+json' ]
     
],
      contentType
: 'APPLICATION_JSON',
      responseHandle
: 'LEAVE_OPEN',
      httpMode
: 'GET',
      url
: 'https://' + Constants.ECR_REPO + '/v2/myrepo/tags/list?n=1000',
      validResponseCodes
: '200'
   
);

   
def response = responseRaw.content
   
def response_status = responseRaw.status
    responseRaw
.close();

   
   
def responseParsed = new groovy.json.JsonSlurperClassic ().parseText(response);

   
return responseParsed['tags'].sort(). reverse();
 
}
This code works just fine in my pipeline both inline and as function from default shared library configured in my Jenkins.
But for Active Choice Parameter I always getting fall back value.

In plain English I'm trying to get list of tags from private docker reposity so that operator would be able to pick image of his interest

Any advice on how to make it working?

Many thanks in advance!

--
You received this message because you are subscribed to the Google Groups "BioUno Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biouno-users...@googlegroups.com
.
To view this discussion on the web visit https://groups.google.com/d/msgid/biouno-users/ba5c5a9b-4c88-4b8e-890b-5b1d16de0da1%40googlegroups.com
.
Reply all
Reply to author
Forward
0 new messages