Using Artifactory plugin for Jenkins, is there a way to search repos for images with a property? - docker

I'm using the Artifactory plugin in Jenkins. I have a situation where I need to pull docker images from Artifactory which have a particular property set. I can search for them using the REST API, but I have not found a way to do this using the Jenkins plugin. Anybody know if there is a way?
Thanks.

This is the download spec schema from the documentation:
{
"files": [
{
"pattern" or "aql": "[Mandatory]",
"target": "[Mandatory]",
"props": "[Optional]",
"recursive": "[Optional, Default: true]",
"flat" : "[Optional, Default: false]"
}
]
}
Where from my point of view you have a couple of options to search by propeties; one would be using aql where you have such option. Second one would be directly using props, which main purpose seems to be exactly that:
props: List of "key=value" pairs separated by a semi-colon. (For
example, "key1=value1;key2=value2;key3=value3). Only artifacts with
all of the specified properties and values will be downloaded.

Related

How to query repository rule in bazel?

I'm trying to translate my company's project from legacy build tool to bazel. Now I'm facing this problem and searched a lot, but unfortunately, I haven't had a clue so far.
Here's the thing:
For compliance with open source audit, we must provide a list of open-source software which are built into our binary. As external dependencies are introduced by repository rules, my intuitive thought is to query these rules and get the URLs. However, subcommand query/cquery hasn't provided such functionality yet AFAIK, it can print rule/target/buildfiles but no repository rules nor their attributes.
Is there a way that I can gather such information from repository rules in WORKSPACE? It's not viable to do it manually as there are thousands of projects in my company and the dependencies also change frequently.
For example, a workspace rule:
http_archive(
name = "testrunner",
urls = ["https://github.com/testrunner/v2.zip"],
sha256 = "..."
)
This dependency is used by a rule named "my_target", so what i expected is that the dependency could be queried like this:
> bazel queryExtDep my_target
External Dependency of my_target: name->testrunner, urls = "https://github.com/testrunner/v2.zip"
--experimental_repository_resolved_file will give you all that information in a single Starlark file, which you can easily process with Starlark or Python etc to extract the information you're looking for.
The resolved file looks something like this:
resolved = [
...,
{
"original_rule_class": "#bazel_tools//tools/build_defs/repo:git.bzl%git_repository",
"original_attributes": {
"name": "com_google_protobuf",
"remote": "https://github.com/google/protobuf",
"branch": "master"
},
"repositories": [
{
"rule_class": "#bazel_tools//tools/build_defs/repo:git.bzl%git_repository",
"attributes": {
"remote": "https://github.com/google/protobuf",
"commit": "78ba021b846e060d5b8f3424259d30a1f3ae4eef",
"shallow_since": "2018-02-07",
"init_submodules": False,
"verbose": False,
"strip_prefix": "",
"patches": [],
"patch_tool": "patch",
"patch_args": [
"-p0"
],
"patch_cmds": [],
"name": "com_google_protobuf"
}
}
]
}
]
This includes the original attributes, which is where that URL you're looking for is. It also includes any additional information returned by the repository rule (ie for git_repository, the actual commit a given ref refers to).
I got that example from blog post introducing that flag, which also has some more background.

Commandline to add and exception in edge to allow download and run JNLP

I have the issue I would like to automate via a script so tat .jnlp will be added as an allowable type of file , is there a command like or powershell or regedit that will add it?
The latest file types policies are published in the Chromium source code. You could clearly see that the danger_level of .jnlp type files is DANGEROUS. Therefor Edge will warn users that this file may harm their computers. Let users continue or discard the file.
If you ensure that the content(download file) on the site is safe, you can use this policy to specify the file types that are allowed to be downloaded continuously from a specific site: ExemptDomainFileTypePairsFromFileTypeDownloadWarnings.
Example:
[ { "file_extension": "jnlp", "domains": ["contoso.com"] }, { "file_extension": "exe", "domains": ["contoso.com"] }, { "file_extension": "swf", "domains": ["*"] } ]
If you want to achieve the same function through the registry, you can set it under this path: SOFTWARE\Policies\Microsoft\Edge\ExemptDomainFileTypePairsFromFileTypeDownloadWarnings

How to add multiple CodeCommit source repository to CdkPipline

I am trying to create a CdkPipeline with multiple source CodeCommit repository.
I followed instructions from cdkworkshop to successfully create a self-mutating pipeline with single CodeCommit repository but cannot figure out how to add more packages (CodeCommit repository) inside the source stage.
I did see examples from https://docs.aws.amazon.com/cdk/api/latest/docs/aws-codepipeline-actions-readme.html#build--test but this does not provide CDK's self-mutating capability.
This example https://docs.aws.amazon.com/cdk/latest/guide/codepipeline_example.html#codepipeline_example_stack seems a bit more promising but it looks too manual.
Any help would be appreciated.
Late to the response, but here is the solution from the AWS Documentation
If you are using a ShellStep for your initial step, utilize the additional_inputs property:
additional_inputs (Optional[Mapping[str, IFileSetProducer]]) – Additional FileSets to put in other directories. Specifies a mapping from directory name to FileSets. During the script execution, the FileSets will be available in the directories indicated. The directory names may be relative. For example, you can put the main input and an additional input side-by-side with the following configuration:: const script = new pipelines.ShellStep(‘MainScript’, { commands: [‘npm ci’,’npm run build’,’npx cdk synth’], input: pipelines.CodePipelineSource.gitHub(‘org/source1’, ‘main’), additionalInputs: { ‘../siblingdir’: pipelines.CodePipelineSource.gitHub(‘org/source2’, ‘main’), } }); Default: - No additional inputs
In the above example, it shows you how to add an additional GitHub repository as an input, and maps it to the file to ../siblingdir in your ShellStep.
This will work for some types of Steps (Example for CodeBuildStep), but it's recommended to check the documentation to confirm.

How can I pass a pointer to a file in helm upgrade command?

I have a truststore file(a binary file) that I need to provide during helm upgrade. This file is different for each target env(dev,qa,staging or prod). So I can only provide this file at time of deployment. helm upgrade --set-file does not take a binary file. This seem to be the issue I found here: https://github.com/helm/helm/issues/3276. This truststore files are stored in Jenkins Credential store.
As the command itself is described below:
--set-file stringArray set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)
it is also important to know The Format and Limitations of
--set.
The error you see: Error: failed parsing --set-file data... means that the file you are trying to use does not meet the requirements. See the example below:
--set-file key=filepath is another variant of --set. It reads the
file and use its content as a value. An example use case of it is to
inject a multi-line text into values without dealing with indentation
in YAML. Say you want to create a brigade project with certain value
containing 5 lines JavaScript code, you might write a values.yaml
like:
defaultScript: |
const { events, Job } = require("brigadier")
function run(e, project) {
console.log("hello default script")
}
events.on("run", run)
Being embedded in a YAML, this makes it harder for you to use IDE
features and testing framework and so on that supports writing code.
Instead, you can use --set-file defaultScript=brigade.js with
brigade.js containing:
const { events, Job } = require("brigadier")
function run(e, project) {
console.log("hello default script")
}
events.on("run", run)
I hope it helps.

Reading parameters in Jenkins from .js or Json file

I have a .js or json file where all my parameters are defined. I want to use this file and have Jenkins read these parameter name from file during build and display such that Suite1 is displayed one job and parameters for Suite2 in another.
For Suite1, jenkins should show smoke and default however for Suite 2 it should show default and Testing in drop down. Can anyone please suggest right way to do it?
module.exports = {
Suite1: {
smoke: ['file1.spec.js','file2.spec.js],
default: ['file3.spec.js']
},
Suite2: {
default: ['file2.spec.js'],
Testing: ['file2.spec.js']
}
}
I tried extended Choice parameter but not getting desired results as there is no way of importing Json file as parameter in there.

Resources