Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix - Broken AQL request when build is not defined in FilesGroup #650

Merged
merged 2 commits into from
Jun 27, 2022
Merged

Bugfix - Broken AQL request when build is not defined in FilesGroup #650

merged 2 commits into from
Jun 27, 2022

Conversation

gsfraley
Copy link
Contributor

@gsfraley gsfraley commented Jun 9, 2022

  • All tests passed. If this feature is not already covered by the tests, I added new tests.

This PR is to fix a bug we've encountered on a group of Jenkins pipelines using the jenkins-artifactory-plugin. The gist is that a call to download artifacts through the jenkins-artifactory-plugin results in a call to AqlHelper with a FilesGroup that doesn't have a build set.

This causes fetchBuildArtifactsSha1 to send a broken AQL request to Artifactory, that ultimately times out (in our case, causing a 504). It used to work when the call went through PatternAqlHelper, which did the search but didn't do the additional filtering by build.

I've posted an example input, the rough callstack to get to this point, and the broken AQL that was sent from fetchBuildArtifactsSha1 below:

artifactoryServer.download(
  failNoOp: false,
  spec: """{
    "files": [
      {
        "pattern": "generic-local/subdir/latest/generic-file.txt",
        "target": "out/subdir/",
        "flat": "true",
        "recursive": "false"
      }
    ]
  }"""
)
// in jenkins-artifactory-plugin
org.jfrog.hudson.pipeline.scripted.steps.DownloadStep.Execution::runStep
org.jfrog.hudson.pipeline.common.executors.GenericDownloadExecutor::execute
org.jfrog.hudson.generic.FilesResolverCallable::invoke
// in build-info-extractor
org.jfrog.build.extractor.clientConfiguration.util.spec.SpecsHelper::downloadArtifactsBySpec
org.jfrog.build.extractor.clientConfiguration.util.DependenciesDownloadHelper::downloadDependencies
org.jfrog.build.extractor.clientConfiguration.util.ArtifactorySearcher::SearchByFileSpec
org.jfrog.build.extractor.clientConfiguration.util.AqlHelper::run
org.jfrog.build.extractor.clientConfiguration.util.AqlHelper::fetchBuildArtifactsSha1
POST /artifactory/api/search/aql HTTP/1.1
Content-Type: text/plain; charset=ISO-8859-1
User-Agent: ArtifactoryBuildClient/2.32.3
Accept-Encoding: gzip,deflate

items.find({"artifact.module.build.name": "null","artifact.module.build.number": ""}).include("name","repo","path","actual_sha1")

I can confirm that this fix results in the pipelines working, based on a build of jenkins-artifactory-plugin with this updated dependency. It ultimately skips the call to fetchBuildArtifactsSha1 if the build name or number isn't provided, since there won't be a useful return result if either isn't present.

@github-actions
Copy link

github-actions bot commented Jun 9, 2022

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@gsfraley
Copy link
Contributor Author

gsfraley commented Jun 9, 2022

I have read the CLA Document and I hereby sign the CLA

@eyalbe4 eyalbe4 self-requested a review June 27, 2022 06:49
@eyalbe4 eyalbe4 merged commit c2dc9f7 into jfrog:master Jun 27, 2022
@gsfraley gsfraley deleted the broken-aql branch June 28, 2022 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants