Gitlab container registry tag expiration policy not working - regex format? schedule? - gitlab

I'm trying the Gitlab "CI/CD > Container Registry tag expiration policy" setting, and so far it's not deleting anything. We use semantic versioning (with a "v" prepended), and my goal is to automatically delete old "patch" releases:
Keep all major & minor tags: vM.0.0 and vM.m.0.
Delete all but a few recent tags matching vM.m.p (where p is not zero)
Given that I'm enabling this new setting on an old project, it's risky to find my answer by experimentation. Even on a new project, experimenting would take a lot of effort and calendar time. A dry-run or preview option would be really nice here, so I could try out the settings without fear of deleting important tags.
I tried the following "expire" regex: v[1-9][0-9]*[.][0-9][0-9]*[.][1-9][0-9]*. So far it hasn't had any effect. Which leaves me wondering:
How often does this run? Do I just need to wait longer?
Am I mis-understanding the way this setting works?
Is my regex bad?
What regex format is expected, even?
A more complex example in the UI would be nice. https://gitlab.com/gitlab-org/gitlab/-/issues/214007#note_322637771 mentioned that, but was closed without addressing that point.
Is there any way to see feedback on this cleanup, like maybe in the project activity log?
My current approach is to tweak this setting once a day, then check my tags list the next day to see if it had any effect.
I'd appreciate general advice for verifying/troubleshooting this setting, and/or specific suggestions for how to match my particular version scheme.
Here's a screenshot of my current settings:

I eventually gave up on this and took a different approach. Probably the most frustrating part was wondering when it runs. Is it once a day at a regular time? A random time each day? Once after every push to the registry? I was never sure how long to wait and see if my settings changes made a difference.
Instead I found an API method that exposes all of the same options. I actually like the API better than a project setting
I can see more clearly how & when it runs.
I can see error messages and results.
I can track the config in git, in .gitlab-ci.yml, rather than having to document a separate project setting.
https://docs.gitlab.com/ee/api/container_registry.html#delete-registry-repository-tags-in-bulk gives an overview and some example curls. Here's how I added it to my pipeline:
# In before_script:
- apk --update add curl
...
# In the job script:
# Get registry id. Assumptions: valid response, "id" is first field, and project only has one registry.
- REGISTRY_ID=`curl --header "PRIVATE-TOKEN:$API_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/registry/repositories" | cut -d, -f1 | cut -f2 -d:`
- TAGS_URL=https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/registry/repositories/$REGISTRY_ID/tags
- curl --request DELETE --data 'keep_n=10' --data 'older_than=1week' --data "name_regex_delete=v[0-9][.].*" --data "name_regex_keep=.*[.]0" --header "PRIVATE-TOKEN:$API_TOKEN" "$TAGS_URL"
Using the API, I was able to quickly figure out which regex patterns worked. It's not immediate, but it seems to take effect within a minute. I'm assuming I could take those same regexes and use them in the project settings, but I'm happier sticking with the API for now.

Related

Title of pullrequest same as Branchname

For pull requests in AzureDevops, im using ALWAYS the branch name as Pull reqeust title.
How can i set the branch name as default value for title?
I don't wanna type it again always :-)
I've checked the pull request templates, but am not able to make it for the title
The only way that I can think of is the use of TamperMonkey, there are lot of custom scripts around. This solution has the disadvantage that tampermonkey has to be installed in each browser individually.
I searched several sources but couldn't find the exact thing, but I think if you know Javascript you can get inspired quickly by stuff like this:
https://gist.github.com/2xAA/e7e91dfe2fb48fb5bdcb5403c3ddce43
https://gist.github.com/robie2011/f1d5735855d5809d88b1b987e0fd2cec

How to add an option to Cucumber report to remove scenarios that have a certain tag

I want to have an option on the cucumber report to mute/hide scenarios with a given tag from the results and numbers.
We have a bamboo build that runs our karate repository of features and scenarios. At the end it produces nice cucumber html reports. On the "overview-features.html" I would like to have an option added to the top right, which includes "Features", "Tags", "Steps" and "Failures", that says "Excluded Fails" or something like that. That when clicked provides the same exact information that the overview-features.html does, except that any scenario that's tagged with a special tag, for example #bug=abc-12345, is removed from the report and excluded from the numbers.
Why I need this. We have some existing scenarios that fail. They fail due to defects in our own software, that might not get fixed for 6 months to a year. We've tagged them with a specified tag, "#bug=abc-12345". I want them muted/excluded from the cucumber report that's produced at the end of the bamboo build for karate so I can quickly look at the number of passed features/scenarios and see if it's 100% or not. If it is, great that build is good. If not, I need to look into it further as we appear to have some regression. Without these scenarios that are expected to fail, and continue to fail until they're resolved, it is very tedious and time consuming to go through all the individual feature file reports and look at the failing scenarios and then look into why. I don't want them removed completely as when they start to pass I need to know so I can go back and remove the tag from the scenario.
Any ideas on how to accomplish this?
Karate 1.0 has overhauled the reporting system with the following key changes.
after the Runner completes you can massage the results and even re-try some tests
you can inject a custom HTML report renderer
This will require you to get into the details (some of this is not documented yet) and write some Java code. If that is not an option, you have to consider that what you are asking for is not supported by Karate.
If you are willing to go down that path, here are the links you need to get started.
a) Example of how to "post process" result-data before rendering a report: RetryTest.java and also see https://stackoverflow.com/a/67971681/143475
b) The code responsible for "pluggable" reports, where you can implement a new SuiteReports in theory. And in the Runner, there is a suiteReports() method you can call to provide your implementation.
Also note that there is an experimental "doc" keyword, by which you can inject custom HTML into a test-report: https://twitter.com/getkarate/status/1338892932691070976
Also see: https://twitter.com/KarateDSL/status/1427638609578967047

Cannot use the Knowledge academic API

I have a problem when I try to use the function similarity proposed in the academic knowledge API.
I tested the following commad to compute the similarity between two string:
curl -v -X GET "https://api.labs.cognitive.microsoft.com/academic/v1.0/similarity?s1={string}&s2={string}" -H "Ocp-Apim-Subscription-Key: {subscription key}"
The error that I get is :
{"error":{"code":"Unspecified","message":"Access denied due to invalid
subscript ion key. Make sure you are subscribed to an API you are
trying to call and provi de the right key."}}
Curl_http_done: called premature == 0
Connection #0 to host (nil) left intact
Can you tell how can I generate the Ocp-Apim-Subscription-Key?
At the moment I used the key generated automatically when I visit the following url : https://labs.cognitive.microsoft.com/en-us/subscriptions?productId=/products/5636d970e597ed0690ac1b3f&source=labs
Thank you for your help
Unfortunately, primarily not an answer to your question, but rather a warning for all with the "same" problem, who could came across the original question like me, as the question helped me to solve a very, very similar problem: check whether you are using api.labs.cognitive.microsoft.com instead of westus.api.cognitive.microsoft.com. But may be you need the opposite.
It seems the whole project has been moved inside Microsoft (see https://www.microsoft.com/en-us/research/project/academic/articles/sign-academic-knowledge-api/, I would bet that this blogpost was at the top of some "entrypoint" blog even yesterday morning, but now I am not able to find this blog, perhaps the things are changing right now) and may be the project is somewhere in the middle of the transition process and not all documentation etc. corresponds with the new state. E.g. https://learn.microsoft.com/en-us/azure/cognitive-services/academic-knowledge/home, in the submenu Reference, links to two "versions" of API which seem to be almost same except for the URLs westus.api... and api.labs..., respectively. But there seem to be no info what is the difference, which one should be preferred etc.
My original keys expired yesterday, thus I generated new ones and was not able to use them until I have changed the URL to api.labs..., thanks to your question. May be you have the opposite problem, that you still have the "old" keys, so you need to use the "old" url westus.api..., but I am not able to test it, as my original keys which worked with westus.api... are expired.
Both your query and your link where to get keys are OK and work for me. Just one additional detail: did you try the circle arrow next to the key value, which generates a new key? May be your key is somehow broken or expired and this could solve your problem. You can also try to create a completely new account at MS site.
PS: I have added microsoft-cognitive tag as MS refers to https://stackoverflow.com/questions/tagged/microsoft-cognitive from many pages related to Cognitive Services
I think you need to sign up for a free account, there is a link you can follow from here:
https://westus.dev.cognitive.microsoft.com/docs/services/56332331778daf02acc0a50b/operations/58076bdadcf4c40708f83791
Except for the invalid key, you curl-call looks right.
You need a valid subscription key to be able to make API calls.
Production key
Have a look at this page on how to created the needed services in the Azure portal and how to find the endpoint, as well as they key from there.
Trial key
However, if you just want to try out the service, you can create a temporary key here. This key is very limited in use but it should get you up and running.
Limitations are:
50,000 transactions per month, up to 20 per second.
Trial keys expire after a 90 day period.

Won't login into JSF application with JMeter

I have a big problem with this. I implemented almost every answer on this kind of questions.
I know for the thing about regex and viewState, and this is how mine looks - regex
And the Cookie Manager is here also - cookie manager
In POST request i changed the javax.faces.ViewState value into ${jsfViewState} .
And the third Sampler with GET request, which represent the home screen value when im login, returns me on login page.
Really can't find what could be problem anymore. I tried almost everything! Did i missed something?
You need to put your Regular Expression Extractor as a child of the 1 - /Login.xhtmlrequest.
You don't need to escape quotation marks, you should be rather escaping dots, but in the most recent JMeter versions it is not requred.
Depending on your application implementation you may also need to add JSESSIONID as a part of your URL
I would recommend using
Debug Sampler and View Results Tree listener combination to double check ${jsfViewState} variable value
Using "RegExp Tester" mode of the View Results Tree listener to test your regular expression against live data
As a last resort you can consider using an alternative way of recording a JMeter test. It is a cloud-based proxy which can automatically detect dynamic values and perform correlation for you, check out How to Cut Your JMeter Scripting Time by 80% article for more details.

Code fragment repository search on github.com

How can I search for code fragments on github.com? When I search for MSG_PREPARE in the repository ErikZalm/Marlin github shows up nothing.
I'm using the repository code search syntax described on https://github.com/search with
repo:ErikZalm/Marlin MSG_PREPARE
No results, but MSG_PREPARE can be found inside this repository here. Am I missing something? Is there no code search on github.com?
At the time of writing this answer, compared to time this question was asked i.e. about 8 years ago, github has come a good way, though still not to the length which you are looking at.
GitHub code searches are limited on the following rules: https://docs.github.com/en/github/searching-for-information-on-github/searching-code . Quoting the same:
Code in forks is only searchable if the fork has more stars than the parent repository.
Forks with fewer stars than the parent repository are not indexed for code search.
To include forks with more stars than their parent in the search results, you will need to add fork:true or fork:only to your query.
For more information, see "Searching in forks."
So we can search within the fork using the fork:true option, though as expected, since the repo ErikZalm/Marlin is low on star count as compared to parent MarlinFirmware/Marlin, the code in the fork is still not indexed. Hence the advance search shows no good except a match to the repo.
Though, if you perform the same search on the parent, it would show the matches on the code. Here are the matches for MSG_PREPARE in the parent repo MarlinFirmware/Marlin
Fortunately, one company which I know working on this domain is SourceGraph: https://about.sourcegraph.com/
Hence, you can easily search what you intended with SourceGraph:
Here are the matches for MSG_PREPARE in the ErikZalm/Marlin using SourceGraph Cloud
Update July 2013: "Preview the new Search API"
The GitHub search API on code now supports fragments, through text-match metadata.
Some API consumers will want to highlight the matching search terms when displaying search results. The API offers additional metadata to support this use case. To get this metadata in your search results, specify the text-match media type in your Accept header. For example, via curl, the above query would look like this:
curl -H 'Accept: application/vnd.github.preview.text-match+json' \
https://api.github.com/search/code?q=octokit+in:file+extension:gemspec+-repo:octokit/octokit.rb&sort=indexed
This produces the same JSON payload as above, with an extra key called text_matches, an array of objects. These objects provide information such as the position of your search terms within the text, as well as the property that included the search term.
Original answer (November 2012)
I don't think there is anything that you would have missed.
If you search for SdFile, you would find results in .pde file, but none in cpp files like in this SdFile.cpp file.
The search was introduced 4 years ago (November 2008), but, as mentioned in "Search a github repository for the file defining a given function", GitHub repository code is simply not fully indexed.

Resources