DevOps extension for servergate - devops

Can I use "target" when I am working for creating extension to runOn servergate? as below?
When I am deploying it, it is not executing the script inside APICall.ps1.
"execution": {
"PowerShell3": {
"target": "ApiCall.ps1",
"workingDirectory": "$(currentDirectory)"
}

Related

Krakend endpoint variable within extra config

I have to use an endpoint variable within extra-config Proxy Flatmap Filter arguments.
...
{
"endpoint": "/cascade/{entity}/{id}/{subentity}/{commonField}",
"backend": [
{
"url_pattern": "/api/{entity}/{id}",
"host": ["http://myapi:8080/"],
"encoding": "json",
"extra_config": {
"proxy": {
"flatmap_filter": [
{
"type": "move",
"args": ["{{commonField}}","customField"]
}
]
}
}
}
]
}
...
I need to get from url commonField and use it within flatmap filter as first value of args array.
But this doesn't work. Is a kind of configuration constraint that I can't use URL variable anyware in the configs?
Although using variables from url_pattern in flatmap_filter is not possible out-of-the-box currently, you can always use Lua scripting or a request/response modifier plugin (using Golang) to achieve that transformations.

Artifactory and Jenkins - get file with newest/biggest custom property

I have generic repository "my_repo". I uploaded files there from jenkins with to paths like my_repo/branch_buildNumber/package.tar.gz and with custom property "tag" like "1.9.0","1.10.0" etc. I want to get item/file with latest/newest tag.
I tried to modify Example 2 from this link ...
https://www.jfrog.com/confluence/display/JFROG/Using+File+Specs#UsingFileSpecs-Examples
... and add sorting and limit the way it was done here ...
https://www.jfrog.com/confluence/display/JFROG/Artifactory+Query+Language#ArtifactoryQueryLanguage-limitDisplayLimitsandPagination
But im getting "unknown property desc" error.
The Jenkins Artifactory Plugin, like most of the JFrog clients, supports File Specs for downloading and uploading generic files.
The File Specs schema is described here. When creating a File Spec for downloading files, you have the option of using the "pattern" property, which can include wildcards. For example, the following spec downloads all the zip files from the my-local-repo repository into the local froggy directory:
{
"files": [
{
"pattern": "my-local-repo/*.zip",
"target": "froggy/"
}
]
}
Alternatively, you can use "aql" instead of "pattern". The following spec, provides the same result as the previous one:
{
"files": [
{
"aql": {
"items.find": {
"repo": "my-local-repo",
"$or": [
{
"$and": [
{
"path": {
"$match": "*"
},
"name": {
"$match": "*.zip"
}
}
]
}
]
}
},
"target": "froggy/"
}
]
}
The allowed AQL syntax inside File Specs does not include everything the Artifactory Query Language allows. For examples, you can't use the "include" or "sort" clauses. These limitations were put in place, to make the response structure known and constant.
Sorting however is still available with File Specs, regardless of whether you choose to use "pattern" or "aql". It is supported throw the "sortBy", "sortOrder", "limit" and "offset" File Spec properties.
For example, the following File Spec, will download only the 3 largest zip file files:
{
"files": [
{
"aql": {
"items.find": {
"repo": "my-local-repo",
"$or": [
{
"$and": [
{
"path": {
"$match": "*"
},
"name": {
"$match": "*.zip"
}
}
]
}
]
}
},
"sortBy": ["size"],
"sortOrder": "desc",
"limit": 3,
"target": "froggy/"
}
]
}
And you can do the same with "pattern", instead of "aql":
{
"files": [
{
"pattern": "my-local-repo/*.zip",
"sortBy": ["size"],
"sortOrder": "desc",
"limit": 3,
"target": "local/output/"
}
]
}
You can read more about File Specs here.
(After answering this question here, we also updated the File Specs documentation with these examples).
After a lot of testing and experimenting i found that there are many ways of solving my main problem (getting latest version of package) but each of way require some function which is available in paid version. Like sort() in AQL or [RELEASE] in REST API. But i found that i still can get JSON with a full list of files and its properties. I can also download each single file. This led me to solution with simple python script. I can't publish whole but only the core which should bu fairly obvious
import requests, argparse
from packaging import version
...
query="""
items.find({
"type" : "file",
"$and":[{
"repo" : {"$match" : \"""" + args.repository + """\"},
"path" : {"$match" : \"""" + args.path + """\"}
}]
}).include("name","repo","path","size","property.*")
"""
auth=(args.username,args.password)
def clearVersion(ver: str):
new = ''
for letter in ver:
if letter.isnumeric() or letter == ".":
new+=letter
return new
def lastestArtifact(response: requests):
response = response.json()
latestVer = "0.0.0"
currentItemIndex = 0
chosenItemIndex = 0
for results in response["results"]:
for prop in results['properties']:
if prop["key"] == "tag":
if version.parse(clearVersion(prop["value"])) > version.parse(clearVersion(latestVer)):
latestVer = prop["value"]
chosenItemIndex = currentItemIndex
currentItemIndex += 1
return response["results"][chosenItemIndex]
req = requests.post(url,data=query,auth=auth)
if args.verbose:
print(req.text)
latest = lastestArtifact(req)
...
I just want to point that THIS IS NOT permanent solution. We just didnt want to buy license yet only because of one single problem. But if there will be more of such problems then we definetly buy PRO subscription.

install plugin for Open Distro

Amazon Elasticsearch Service offers k-Nearest Neighbor (k-NN) search which can enhance search by similarity use cases.
https://aws.amazon.com/about-aws/whats-new/2020/03/build-k-nearest-neighbor-similarity-search-engine-with-amazon-elasticsearch-service/
I tried this official code that I found here...
https://github.com/opendistro-for-elasticsearch/k-NN
PUT /myindex
{
"settings" : {
"index": {
"knn": true
}
},
"mappings": {
"properties": {
"my_vector1": {
"type": "knn_vector",
"dimension": 2
},
"my_vector2": {
"type": "knn_vector",
"dimension": 4
},
"my_vector3": {
"type": "knn_vector",
"dimension": 8
}
}
}
}
Getting this error:
"unknown setting [index.knn] please check that any required plugins
are installed, or check the breaking changes documentation for removed
settings"
How do I check if my Elastic installation supports this feature?
t2.small and t2.medium instance types are not supported. (It is not mentioned anywhere in the documentation.) It worked as expected when r5.large instance type was selected.

Access single object in model using Metalsmith and swig

I have a json data file with multiple objects with named keys in it.
{
"berlin:" : {
"location": "Berlin",
"folder": "berlin-2016"
},
"seattle" : {
"location": "Seattle ",
"folder": "seattle-2016"
}
}
In my content file I would like to specify which object in the model to use and then refer to that in swig. Something like this:
---
model:
conference: conferences['berlin']
---
{{ model.conference.location }}
Is this possible?
That's definitely possible with metalsmith. I don't have a complete picture of your build process, but for this solution you'll have to use the metalsmith javascript api:
./data.json
{
"berlin:" : {
"location": "Berlin",
"folder": "berlin-2016"
},
"seattle" : {
"location": "Seattle ",
"folder": "seattle-2016"
}
}
./build.js
// Dependencies
var metalsmith = require('metalsmith');
var layouts = require('metalsmith-layouts');
// Import metadata
var metadata = require('./data.json');
// Build
metalsmith(__dirname)
// Make data available
.metadata(data)
// Process templates
.use(layouts('swig'))
// Build site
.build(function(err){
if (err) throw err;
});
Then run node build.js in your root project folder to build. In your templates the data from data.json would then be available as {{ berlin.location }}.
You can also do this without the javascript api (which I don't recommend because you lose some flexibility), in which case you would use a plugin (for example: metalsmith-json)

How do you add an app's icon (app made with Trigger.io) to the iOS content sharing menu

I'm creating an iOS application using trigger IO, and I would like to add my application's shortcut icon to the list of available editors for certain file types. Like in this article, can this be done using trigger io?
My app inside iMessage UIActivityViewController
I've added the build_steps.json to the ios custom module. I can't get the correct syntax. I get an error from the forge build procress.
[ ERROR] 2013-11-29 22:29:56,654 -- set_in_info_plist() got an unexpected keyword argument 'UTImportedTypeDeclarations'
Here is my build_steps.json:
[
{
"do": {
"set_in_info_plist": {
"UTImportedTypeDeclarations":
[
{
"UTTypeConformsTo":
[
"public.image"
],
"UTTypeIdentifier": "public.png",
"UTTypeTagSpecification":
{
"com.apple.ostype": "PNG",
"public.filename-extension":
[
"png"
],
"public.mime-type": "image/png"
}
},
{
"UTTypeConformsTo":
[
"public.image"
],
"UTTypeIdentifier": "public.jpeg",
"UTTypeTagSpecification":
{
"com.apple.ostype": "JPEG",
"public.filename-extension":
[
"jpg"
],
"public.mime-type": "image/jpeg"
}
}
]
}
}
}
]
Can anyone tell me what is wrong with this file?
This isn't possible with Trigger's built in functionality, but should be possible by writing your own native module.
See https://trigger.io/docs/current/api/native_modules/index.html and in particular https://trigger.io/docs/current/api/native_modules/native_build_steps.html#set_in_info_plist for updating the Info.plist for an app.

Resources