Pass variable from Pre step to Build Step in Maven Jenkins Job - maven

I have a maven job that runs a pom.xml file with some goals I provide like below:
Pom File: pom.xml
goals: test -DsuiteName=testng.xml
Now I want to add a radio button parameter into this job "Run_Failed_Cases_Only", if user selects this then instead of testng.xml I want to pass testng-failed.xml file. like below:
Pom File: pom.xml
goals: test -DsuiteName=testng-failed.xml
So what I want is if there is any way I can use windows batch command step, that will check if "Run_Failed_Cases_Only" is selected then pass a variable $goals to the build step as per the condition below:
if(Run_Failed_Cases_Only is selected)
$goals = "test -DsuiteName=testng-failed.xml"
else
$goals = test -DsuiteName=testng.xml
then I will use this variable in the goals text box.

When you have created the Maven Project job, select the option This project is parametrized from General tab. If the Extensible Choice Plugin is not installed, install it then you can find the same here in This project is parametrized
Please find the screenshot below.
Then, you can use the specific condition based on the choice parameter.
OR
Alternatively, You can also use Generator Choice parameter available in This project is parameterized to get the result.
Please find the screenshot.
Then, you can use the specific condition based on the choice.

Solved this by using Extended Choice Parameter and providing different display name and values like below:
then used this parameter as variable in POM like below:

Related

Is there a way to specify a where condition for all tests in a model in DBT?

I would like to write some tests for my dbt model. I only want the tests to test certain rows (data within the last month). I could write a where clause for every single test in yml file like so:
- not_null
config:
where: "current_date-date_column<=30"
However, I was wondering if there is some shortcut to put the clause on the model and have the where clause apply to all tests of the model (which is a lot easier to write and also means I don't have to worry about forgetting if I add more tests).
This article givers an example on how to do that for project level but I don't want the whole project just one model.
Any config that can be applied in the dbt_project.yml can be scoped to specific directories or resources. However, tests are their own resources, independent of the models they test, and currently (dbt v1.2), it is not possible apply config to all tests for a given model.
As a workaround, you could consider putting the .yml file that defines the tests for that model in a directory by itself, and applying the config to a directory.
Apply where to a whole project:
tests:
+where: "date_column = current_date"
Apply where only to .yml files nested in the models/marts/finance/ directory:
tests:
my_project:
marts:
finance:
+where: "date_column = current_date"
Apply where to a specific test:
tests:
my_project:
marts:
finance:
not_null_revenue_id:
+where: "date_column = current_date"
See the docs for resource-path for more info

Embed parameter in another parameter name in teamcity

An example:
I am using autoinc feature in teamcity so whenever I change the version of my build I would like to change it only in one place.
%buildversion% is 5.0
so I would like to do the following:
%autoinc.buildname_%buildversion%%
to get %autoinc.buildname_5.0%.
Basically every time I change the version autoinc counter will be reseted.
Create the Paraemters
Create a Combined Paramter

How to execute findbugs programmatically with selected rules and classes?

I have a very large code base.
I would like to execute findbugs programmatically on selected class files with just a selected set of rules at a time so that the analysis can finish in a few seconds. Documentation for includes/excludes say that only matching patterns will be reported, but does not clarify whether all the rules will be processed or only the selected ones.
Would like to know where I can start?
If you are using ant and findbugs anttask, to run a selected set of bug-detectors, use the "visitors" parameter/attribute.
More details here:
http://findbugs.sourceforge.net/manual/anttask.html
To run on selected classes only, I just jar-ed the selected classes in a separate jar and pointed the ant task to it via the "class" sub-tag.

How can I change the execute order for Magmi plugins?

I'm working on importing (on a regular basis) about 6,000 items into Magento using Magmi. I've got nearly everything configured the way I need it, but I have one issue.
I need to concatenate 3 columns from my .csv file to create a "category_ids" column. I'm using the Value Replacer plugin with the following value:
{item.departmentid},{item.classid},{item.subclassid}
This works well, however I need to then map this field to another field using the Generic Mapper plugin. Both functions work individually, however I need the Value Replacer to run BEFORE the Generic Mapper. As best as I can tell, it appears the Generic Mapper runs first. Is there a way I can alter the execute order for these two plugins?
Thanks for the help!
Update for Dweeves:
Doh! I totally overlooked that section while trying to figure this out. Now that I've gone through it, I might need a little more help. Right now I've using just the Value Replacer plugin with the following settings:
Replaced attributes: category_ids
New value for category_ids:
{{ ValueRemapper::use_csv('/var/www/magmi/category_ids.csv')->map({item.departmentid},{item.classid},{item.subclassid}) }}
It doesn't seem to be working as I intended it to, but I'm a systems guy and not a PHP programmer. Any help?
2nd Edit
I got it working by using the Value Replacer function to first concatenate everything into a new "test" column, then using the Value Replacer Value Mapper function to create the category_ids column with the mapped values. Confusing, but it's working well.
You can use the ValueRemapper helper of Value Replacer plugin for this kind of purpose.
See Value Replacer Plugin Documentation (ValueRemapper helper section)
To answer your original question (how to define the order the plugins run in).
From my experience, the plugins are loaded in order of their plugin filename.
For example, if you look at magmi/plugins/base/itemprocessors/importlimiter, you will notice that the filename for the plugin is 01_importlimiter.php.
If you look in the genericmapper plugin folder, you'll notice the plugin filename to be 02_genericmapper.php.
With this being said, 01_importlimiter.php will execute before 02_genericmapper.php.

Filter to show sub tasks of a filtered list of parent tasks

I have a JIRA filter which returns all the fixes in a future release:
project = MyProject AND fixVersion = "1.1.1" and issuetype in standardIssueTypes() and status != Closed
All of these issues have Sub-Tasks which I want to have in a new filter result. They do not have the fixVersion set.
I have tried the parent filter but this only accepts Key or ID.
Is there any way I can write a filter to access these without manually using something like parent in (MyProject-1,MyProject-2,MyProject-3,MyProject-4,etc)?
You can install the Craftforge JQL functions
https://plugins.atlassian.com/plugin/details/31601
You then create a filter
project = MyProject AND fixVersion = "1.1.1" and issuetype in standardIssueTypes() and status != Closed
Call this filter for example 'parentIssues'
Using the JQL
issue in subtaskIssuesFromFilter("parentIssues")
will retrieve all relevant subtask issues.
I have a solution that requires no plugins whatsoever, but some manual work that is much better than listing the tasks in the query itself:
Using the linkedIssues function, you can write a query like so
parent in linkedIssues("PROJ-1061")
Now, link all the issues you want in this query to the PROJ-1061 and you're golden. You can do this in a bulk job, you can also add it as a trigger in a workflow potentially.
Use Script Runner plugin and a query like:
issueFunction in subtasksOf("project = MyProject AND fixVersion = 27_04_2013 and status != Closed"))
JQL Tricks adds tons of additional JQL functions: https://marketplace.atlassian.com/plugins/com.j-tricks.jql-plugin
Here an example for the above using their syntax:
issue in parent("project = MyProject AND fixVersion = 27_04_2013 and status != Closed")
There is no need for any Plugin.
Switch to "Advanced" filter option and enter
status in ("Open") AND parent in (PHX-xxx,ENG-xxx)
It will give you all the open tickets present as a subtask in parent JIRAs. Build more complex and enjoy using JIRA. Advanced filter options will also give you all possible values to build Queries.

Resources