jenkinsci / jenkinsci/jfrog-plugin
config file is lock under a tmp folder
- Dominant language
- Java
- Stars
- 16
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the bug
During JFrog installation, even if you set the JFROG_CLI_HOME env variable to set the home dir, the CLI creates the home dir under a tmp/ folder, which causes an issue where user cannot add the Artifactory public cert to JFrog CLI later via `$JFROG_CLI_HOME/.jfrog/security/certs`
### Current behavior
During JFrog installation, CLI creates the JFROG_CLI_HOME under a temp dir, as seen in the debug output around creation of the config file lock under a tmp/ folder:
`[gradle-example-ci-server] $ /var/jenkins_home/tools/io.jenkins.plugins.jfrog.JfrogInstallation/jfrog-cli/jf c add arty --user=arty@jfrog.com ******** --url=https://arty.jfrog.io/ --artifactory-url=https://arty.jfrog.io/artifactory --distribution-url=https://arty.jfrog.io/distribution --xray-url=https://arty.jfrog.io/xray --interactive=false --overwrite=true
16:38:23 [Debug] JFrog CLI version: 2.62.0
.
.
.
16:38:23 [Debug] Locking config file to run config AddOrEdit command.
16:38:23 [Debug] Creating lock in: /var/jenkins_home/workspace/test/gradle-examples/gradle-example-ci-server**@tmp/jfrog/37/.jfrog/locks/config**
16:38:23 [Debug] config file is released.`
Because of this, when user passed the public cert via `JFROG_CLI_HOME/.jfrog/security/certs`, it wasn't added to JFrog CLI and caused this error:
`19:58:38 [Error] The following error was received while trying to encrypt your password:
Get "https:///artifactory/api/security/encryptedPassword": tls: failed to verify certificate: x509: certificate signed by unknown authority`
### Reproduction steps
Install JFrog Plugin to Jenkins, configure Artifactory connection, run example Jenkins pipeline script:
`pipeline {
agent any
environment {
JFROG_CLI_LOG_LEVEL = "DEBUG"
JFROG_CLI_RELEASES_REPO = "artifactory/jfrog-cli-remote"
JFROG_CLI_BUILD_NAME = "test-gradle"
JFROG_CLI_BUILD_NUMBER = "1.0.0"
JFROG_CLI_HOME = "/var/jenkins_home/workspace/test/gradle-examples/gradle-example-ci-server"
}
tools {
jfrog 'jfrog-cli'
}
stages {
stage('Clone') {
steps {
git branch: 'master', url: "https://github.com/jfrog/project-examples.git"
sh 'echo $JFROG_CLI_HOME'
}
}
stage('Exec Gradle commands') {
steps {
dir('gradle-examples/gradle-example-ci-server') {
jf '--version'
// Configure Gradle project's repositories
jf 'gradle-config --repo-resolve test-gradle-dev --repo-deploy test-gradle-release--uses-plugin'
// Install and publish project
jf 'gradle clean artifactoryPublish -b */build.gradle --build-name=$JFROG_CLI_BUILD_NAME --build-number=$JFROG_CLI_BUILD_NUMBER'
}
}
}
stage('Publish build info') {
steps {
jf 'rt build-publish $JFROG_CLI_BUILD_NAME $JFROG_CLI_BUILD_NUMBER'
}
}
}
}`
### Expected behavior
There should be a way to set the JFROG_CLI_HOME variable when running jf commands in jenkins.
### JFrog plugin version
1.5
### JFrog CLI version
2.60.0
### Operating system type and version
macOS - 14.4.1 - 23E224
### JFrog Artifactory version
_No response_
### JFrog Xray version
_No response_
Contributor guide
Research direction
Reproduce the Jenkins pipeline using the JFROG_CLI_HOME environment variable and the jf commands shown, then trace how the plugin invokes JFrog CLI and creates the temporary config lock. Done means the configured home is honored during Jenkins runs, including the .jfrog/security/certs path, and the certificate is used without the reported TLS error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100