I am using the flexible publish plugin for jenkins and found it very useful. My goal is to pass a set of predefined parameters from a job to trigger another downstream job. The downstream job performs an action based on the string match evaluation. But if i dont pass the parameters the job would fail saying
Exception caught evaluating condition: [org.jenkinsci.plugins.tokenmacro.MacroEvaluationException: Unrecognized macro 'multinodeind' in '${multinodeind}'], action = [Fail the build]
I want to do an if else flow. If the parameter is present evaluate it and proceed. Otherwise perform another action. Any clue?
You know you can add parameters with default values under Meta Data → ☑ This build is parameterized → Add parameter, do you? The default values are supposed to be taken if a value for a parameter isn't passed, IIRC.
However, you can use the Conditional BuildStep Plugin in the project configuration's Build section:
A buildstep wrapping any number of other buildsteps, controlling their execution based on a defined condition.
Related
I am trying to install one from two features based on the value that should be set inside of the custom action.
Firstly, I set the value of a property:
UINT __stdcall ConfigurationCheckAction(MSIHANDLE hInstall)
{
HRESULT hr = S_OK;
UINT er = ERROR_INSTALL_FAILURE;
hr = WcaInitialize(hInstall, "ConfigurationCheckAction");
if (condition) {
MsiSetProperty( hInstall, TEXT("STREAM"), TEXT("RED") );
}
else {
MsiSetProperty( hInstall, TEXT("STREAM"), TEXT("BLUE") );
}
return WcaFinalize(er);
}
Secondly, I make two conditions per two features:
<Feature Id='Complete' Level='1'>
<Feature Id="Red" ConfigurableDirectory="TARGETDIR" Title="F1" Level="0">
<Condition Level="1">STREAM</Condition>
</Feature>
<Feature Id="Blue" ConfigurableDirectory="TARGETDIR" Title="F2" Level="0">
<Condition Level="1">NOT STREAM</Condition>
</Feature>
</Feature>
Note that I don't define property inside of the wxs file previously, as I would like to set it from the custom action.
My custom action is called before InstallInitialize and Execute is immediate.
From the installation log I have confirmation that the property is set.
However, my conditional installation does not work, as it seems like what is in the condition is always evaluated as false.
I tried evaluating conditions:
STREAM, STREAM=RED, STREAM="RED", < ![CDATA[STREAM=RED]]>
I am running out of ideas what to do and would appreciate help.
Too late to test all of this, but here goes with some information. I will check back tomorrow. Essentially I think the problem is your custom action sequencing. Try before Costing.
Some things to consider:
Custom action sequencing: you need to sequence your custom action right and it needs to be present in both silent and interactive installation modes.
Did you try to sequence the set property custom action before CostInitialize? You state you set it before InstallInitialize, but try it before CostInitialize instead (you might have tried).
And did you remember to insert this custom action in the InstallUISequence as well as the InstallExecuteSequence? You need to insert in both sequences in case the setup runs in silent mode. Before CostInitialize in both sequences I believe.
Feature Level: manipulating features via the feature level and INSTALLLEVEL is just one way to do feature control, you can also set features via the command line or using a custom action.
Setting a feature level to 0 should hide the feature from view in the setup's custom dialog.
Setting a feature level higher than the setup's INSTALLLEVEL will deselect the feature from installation.
And the other way around setting a feature level lower or equal to the setup's INSTALLLEVEL will select the feature for installation.
The conditional syntax allowed is quite flexible, and could provide the functionality you need outright - but I have never used them properly. Here is an example from the Installshield forum.
ADDLOCAL & REMOVE: you can manipulate the feature selection by changing the values of the ADDLOCAL and REMOVE properties from a custom action (technically also REINSTALL and ADVERTISE) - and these properties can be set via the command line as well.
Win32: you can also use the Win32 functions MsiGetFeatureState and MsiSetFeatureState - from a C++ custom action - to set feature selection.
Frankly it is a bit mad the whole thing. Also keep in mind that there are feature action states (what is going to happen to a feature) and feature installed states (what state it is in). The Win32 function documentation should explain.
Cross-linking for easy retrieval:
Unselected Feature Being Installed
I have done something similar, but we ended up controlling this at a component level(adding the condition to the <Component/> elements instead of the feature element using a transform during heat). But our condition utilizes CDATA while also using double quotes for the value, which you don't list in what you've tried. So first I'd try the following conditions in your features:
<Condition><![CDATA[STREAM="RED"]]></Condition>
<Condition><![CDATA[STREAM="BLUE"]]></Condition>
If that still does not work, I would try the following:
Add the STREAM property with a default value to your WiX. Then test it with that default value to see if having the default value set to begin with makes it work. That could mean you need to set the property sooner, possibly off a UI event. <Property Id="STREAM" Value="RED"/>
As a last resort, you could add the conditions to each component as I did, but we only did that for very specific reasons, hopefully you can get the conditional feature to work with the above suggestions!
I hope the above fixes your problem, or at least leads you to the answer!
Thank you for your replies. In the end, a combination of your suggestions helped me.
I want to state what did and what did not work:
Adding property to WiX with a default value was not necessary (as well with adding property of this property Secure='yes')
Calling custom action before CostInitialize did not solve the problem on its own, but I believe it was one of the factors that resolved an issue.
Conditional sintax was corrected by:
a) Putting condition inside of CDATA and adding quotes to the value of property as suggested: <Condition><![CDATA[STREAM="RED"]]></Condition>
b) Reversing condition levels so feature has condition level 1 and condition has level 0. This means that feature is always installed, unless the condition expression is false.
Concerning the correct order of the custom actions, the description of the custom action type 51 contains the decisive hint:
"To affect a property used in a condition on a component or feature, the custom action must come before the CostFinalize action in the action sequence."
I have a trigger which acts after 3 checks of ping. Interval of checks 3 minutes.
I need to send message like:
Host unavailable from [time of first unsuccessfully check];
Trigger [time of trigger acts]
Which macros i need to use?
With the comment about scripts I'll offer the following.
Configuration/Actions allow you to specify the content of a message. That message can be thought of as simply passing parameters to something. The easy default is that it sends email, but the same parameters can be passed to a script.
Inside the Operations section, you specify the operation as to whom to send (again, think of this as a parameter), and what media type. The user/groups become a parameter as well.
Under Administration, Media types, you can define a media type of "Script". This invokes an external script you write, and passes to it parameters, which by default the first three are the send-to, subject, and message content. You can (in later Zabbix versions) include other parameters there as well (I do not recall if there is a limit). Before that, I started just passing any data I wanted in a predictable and delimited fashion in the message body, then I parse it out inside my script.
Inside the script itself, you pick up the strings passed in, and do whatever you want. So if one parameter (subject, explicitly a 4th+ parameter, or buried in a predictable place inside the body of the message) is a time, you can then operate on that time in the language of your choice, replace it, expound upon it, etc. Then when you have what you want, you send the message from within the script as desired.
Different actions can send using different media types, so you could do a script only for certain types of triggers, based on the conditions written in the action (e.g. a specific trigger name). So you can use default behavior for some, and custom-write other triggers as desired. The key is to have predictable format in the Config/Action/Triggers, and depend on that format in the Administration/Media types parameters, and inside the script they call. Don't forget to make the script accessible to the zabbix service account and place in the location specified in the zabbix config file. I find it useful to stick with an email-format, then I can "test" my actions by just emailing them, take the resulting email and use it to call my scripts outside of zabbix and ensure they work.
The ability to extend the default alerts by using scripts (and in turn a callable interface to zabbix server itself that can pull additional data from zabbix at script execution) makes alerting a bit arcane, but incredibly powerful. In general you can dynamically include almost anything, including graphs, in the alerts by reacting to the script parameters, and pulling together data to email.
In Teamcity 9.*
I have a Build Template with some Configuration parameters that will be different depending on the project that will be created from it.
This parameter is important and must be entered during creation otherwise the build will not work. So my question is:
Is there a way to configure this parameter as Mandatory during Build Creation Dialog?
Teamcity actually has the Name field as mandatory.
I tried to define the parameter as "Text" and with validator "Not Empty". Also using the REGEX but without success. This kind of validator seems to work only running the Custom Builds.
No, unfortunately there is no way to achieve this.
The only way to see this is by looking at your parameters after you've created a build configuration from a template and this will show the required parameters (i.e. they are referenced in build steps / other variables somewhere)
Here you can see a configuration based on a template. The values aren't set in the template or at the point of creating the build configuration
If you fail to supply any of these values, then your build will sit in the build queue and the error message will be "unable to run on any agents due to missing parameter values"
Suppose we have a build project which takes a list member as a parameter.
Can I make another build which could run the first project with all parameters from list sequentially?
If I understand you correctly you want to reliably trigger multiple builds of type A based on a list you pass to build B.
What you could do is have B parse the list (using powershell or whatever else custom program you want to use) and then use the TeamCity REST API to trigger builds of type A with the right parameters, the syntax described here would apply to this:
To trigger a build with custom parameters (system properties and
environment variables), use:
http://testuser:testpassword#teamcity.jetbrains.com/httpAuth/action.html?add2Queue=bt10&name=&value=&name=&value=
This allows you to pass the parameters you need for each build.
I have several Jenkins parameterized jobs that uses the same parameters and parameters values.
When I have to change the default value of one of those parameters, I need to go over all of those jobs and reconfigure them.
A simple solution to this problem would be an option to retrieve all parameters from config file (in the master/ in the workspace) but I could not find a sufficient implementation for that.
I want to be able to feed build with standard Java config file (in format "key"="value") and then refer to those parameters like every other parameters during the build.
Do you know of an appropriate solution?
Use EnvInject Plugin to read your parameters from a file as environment variables in an Inject Environment Variables build step. The glitch is that then you can't override them easily. One solution would be to use it in conjunction with the Conditional BuildStep Plugin. You can then can define a boolean parameter OVERRIDE that would be false by default. You can then run your Inject build step conditionally only when OVERRIDE is false. When you need to override your parameters with values provided by hand (on in a custom call to run the job) specify the override values and set OVERRIDE to true.
I use hudson with ant and set parameters (customer) in my hudson job. This parameter is then the name of a property file that i open with ant as follow:
<loadproperties> srcFile="${project.dir}/build/resources/${customer}.properties"/>