如何根据环境名称搜索Aritfactory构建工件?

时间:2022-12-04 08:15:56

The Build Info JSON for my build in Artifactory contains this:

我在Artifactory中构建的构建信息JSON包含:

{
"properties": {
    "java.vendor": "Oracle Corporation",
    "sun.java.launcher": "SUN_STANDARD",
    "sun.management.compiler": "HotSpot 64-Bit Tiered Compilers",
    "buildInfo.env.CLASSPATH": "",
    "os.name": "Linux",
    "buildInfo.env.GIT_BRANCH": "origin/my-branch-name",
},
"version": "1.0.1",
"name": "my-project",
"number": "359",

I want to use AQL to search for artifacts created from a specific branch name.

我想使用AQL来搜索从特定分支名称创建的工件。

If I search with the project name and build number I get results.

如果我使用项目名称和内部版本号进行搜索,我会得到结果。

items.find({
  "@build.name":"my-project",
  "@build.number":"359"
}).include("*")

However, if I try to search within the properties I don't.

但是,如果我尝试在属性中搜索,我不会。

items.find({
  "@build.properties.buildInfo.env.GIT_BRANCH": "origin/my-branch-name"
}).include("*")

How do I search within these properties? i.e. the environment variables of the build.

如何在这些属性中搜索?即构建的环境变量。

2 个解决方案

#1


2  

You need to do something like

你需要做点什么

items.find({
  "item.artifact.module.build.properties.@buildInfo.env.GIT_BRANCH" : {"$eq" : "origin/my-branch-name"}}
})

#2


0  

Instead of searching the build info I decided to modify jenkins to add the GIT_BRANCH as a build property.

我没有搜索构建信息,而是决定修改jenkins以将GIT_BRANCH添加为构建属性。

I can now search like this:

我现在可以像这样搜索:

items.find({
    "@build.name":"my-project",
    "@build.branch":{"$match":"*my-branch-name*"},
    "name":{"$match":"*.tar.gz"}
}).include("*")

#1


2  

You need to do something like

你需要做点什么

items.find({
  "item.artifact.module.build.properties.@buildInfo.env.GIT_BRANCH" : {"$eq" : "origin/my-branch-name"}}
})

#2


0  

Instead of searching the build info I decided to modify jenkins to add the GIT_BRANCH as a build property.

我没有搜索构建信息,而是决定修改jenkins以将GIT_BRANCH添加为构建属性。

I can now search like this:

我现在可以像这样搜索:

items.find({
    "@build.name":"my-project",
    "@build.branch":{"$match":"*my-branch-name*"},
    "name":{"$match":"*.tar.gz"}
}).include("*")