jfrog / jenkins-jfrog-plugin

Easy integration between Jenkins and the JFrog Platform.
https://github.com/jfrog/jenkins-jfrog-plugin
Apache License 2.0
39 stars 17 forks source link

Support proxy for the CLI tool installation #24

Closed amandel closed 1 year ago

amandel commented 1 year ago

Is your feature request related to a problem? Please describe.

The feature to automatically install the CLI tool does not seem to work in environments that need a http proxy to be used. I could not find a way to set a proper proxy and in the install process immediately get a java.net.UnknownHostException: releases.jfrog.io.

Describe the solution you'd like to see

Describe alternatives you've considered

No response

Additional context

No response

harbulot commented 1 year ago

Not sure if it helps, but does the second method mentioned in the documentation (Automatic installation from Artifactory) work better?

If your build nodes can communicate with a local Artifactory installation, this should in principle be able to cache the download and not require an external connection.

yahavi commented 1 year ago

Hello @amandel & @harbulot, Thanks for using the Jenkins JFrog plugin.

We created https://github.com/jfrog/jenkins-jfrog-plugin/pull/42 to support using the native Jenkins plugin's proxy. We'd appreciate any feedback about the implementation.

yahavi commented 1 year ago

@amandel, Jenkins JFrog plugin 1.1.0 is released. This version includes support for HTTP/S proxy. We'd appreciate your feedback on that!

amandel commented 1 year ago

Hi @yahavi , thanks for looking into this,.

the download now works fine if executed on the built-in node:

Download 'jf' latest version from: https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf/[RELEASE]/jfrog-cli-linux-amd64/jf

Unfortunately on a remote ssh agent, I get the following exception:

Also:   hudson.remoting.Channel$CallSiteStackTrace: Remote call to linux-perm-129
        at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1784)
        at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:356)
        at hudson.remoting.Channel.call(Channel.java:1000)
        at hudson.FilePath.act(FilePath.java:1192)
        at hudson.FilePath.act(FilePath.java:1181)
        at io.jenkins.plugins.jfrog.BinaryInstaller.performJfrogCliInstallation(BinaryInstaller.java:163)
        at io.jenkins.plugins.jfrog.ArtifactoryInstaller.performInstallation(ArtifactoryInstaller.java:67)
        at hudson.tools.InstallerTranslator.getToolHome(InstallerTranslator.java:70)
        at hudson.tools.ToolLocationNodeProperty.getToolHome(ToolLocationNodeProperty.java:109)
        at hudson.tools.ToolInstallation.translateFor(ToolInstallation.java:221)
        at io.jenkins.plugins.jfrog.JfrogInstallation.forNode(JfrogInstallation.java:50)
        at io.jenkins.plugins.jfrog.JfrogInstallation.forNode(JfrogInstallation.java:32)
        at org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:157)
        at org.jenkinsci.plugins.workflow.steps.ToolStep$Execution.run(ToolStep.java:138)
        at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
java.lang.IllegalStateException: Jenkins.instance is missing. Read the documentation of Jenkins.getInstanceOrNull to see what you are doing wrong.
    at jenkins.model.Jenkins.get(Jenkins.java:814)
    at io.jenkins.plugins.jfrog.Utils.createProxyConfiguration(Utils.java:92)
    at io.jenkins.plugins.jfrog.BinaryInstaller.downloadJfrogCli(BinaryInstaller.java:95)
    at io.jenkins.plugins.jfrog.BinaryInstaller$1.invoke(BinaryInstaller.java:166)
    at io.jenkins.plugins.jfrog.BinaryInstaller$1.invoke(BinaryInstaller.java:163)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3578)
    at hudson.remoting.UserRequest.perform(UserRequest.java:211)
    at hudson.remoting.UserRequest.perform(UserRequest.java:54)
    at hudson.remoting.Request$2.run(Request.java:377)
    at hudson.remoting.InterceptingExecutorService.lambda$wrap$0(InterceptingExecutorService.java:78)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)
/export/sbs/jenkins/home/jobs/.../workspace/...-jfrog-cli-test-pipeline@tmp/jfrog/44/.jfrog deleted

In the Jenkins log I see:

Mar 14 06:36:41 sbs-test jenkins[68617]: 2023-03-14 05:36:41.042+0000 [id=637]#011WARNING#011o.j.r.u.AnonymousClassWarnings#warn: Attempt to (de-)serialize anonymous class io.jenkins.plugins.jfrog.BinaryInstaller$1 in file:/export/sbs/jenkins/home/plugins/jfrog/WEB-INF/lib/jfrog.jar; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/

I'm not 100% sure if it is related. There is only one such log Message but I tried several times.

My pipeline looks as follows:

pipeline {
    agent { 
        label 'linux'
//        label 'built-in'
    }
    tools {
        jfrog 'jfrog-cli-proxy-test'
    }
    environment {
        JFROG_CLI_LOG_LEVEL = 'DEBUG'
        JFROG_CREDS = credentials('andreas-test-creads') 
    }
    stages {
        stage ('Testing') {
            steps {
                // Show the installed version of JFrog CLI.
                jf '-v'
...

I've to say after the 1st steps, today I have a jf installed on all build nodes via ansible and also put it into all Containers we use during the build. For now this seems to be the better way for my integration needs.

Kind regards, Andreas.

yahavi commented 1 year ago

@amandel thanks for the feedback. We are terribly sorry for the SSH agents issue and we are working to resolve it quickly. We created this PR to resolve it - https://github.com/jfrog/jenkins-jfrog-plugin/pull/52.

yahavi commented 1 year ago

@amandel, Jenkins Artifactory plugin 1.2.0 is released and will be available shortly in the Jenkins plugin manager. This version includes the fix for the SSH agents issue. We'd appreciate your feedback on that! 🙏🏼

amandel commented 1 year ago

That a quick turnaround. I can confirm the install now works also for ssh agents. 👍 Thanks!

yahavi commented 1 year ago

Thanks for the response, @amandel. I'm glad to hear that it worked for you.

Thank you for helping us to improve this plugin!