date time directory name global variable in capistrano - capistrano3

How can I make a datetime global directory variable in Capistrano 3? Basically the scenario is: I want to create that variable before deploy start and make it available to other tasks. The value of the variable is date and time. So that will be used for backup tasks. How is it possible?
Thanks in advance.

In your deploy.rb, you can set a variable (set :my_datetime, Time.now) and then use it elsewhere (fetch :my_datetime).

Related

Generate random release name bamboo

I'm trying to generate a random release-name by using the Bamboo Server's deployment project / plan.
I was able to generate a dynamic version number by using variables (defined the bamboo.release_number, bamboo.release_major, etc.)
resulting a release name of "StaticName-1.2"
I would like to define on each release that the StaticName will be generated randomly, based on predefined array or list.
The wanted result is by giving it the list of: ["NameA", "NameB", "NameC"]
Bamboo will generate something else on every run, like:
"NameB-1.3"
"NameC-1.4"
"NameA-1.5"
Any ideas how can I preform such thing?
Generally, you can add a build task to write the release name to a file in the project in the format of KEY=VALUE. You would then add an inject variables task to read that file, adding the variables to the plan. You can then reference that variable when creating the release just as you did for the build number.

How to start multiple SID at same time in oracle 11g

I have created 4 listeners and 4 instances in a DB assigning different ports. I can able to up a single instance at a time using (Set ORACLE_SID = 'SID name').I need to up all 4 instances at same time. Is that possible, how can i do this ?
Simply, you can achieve by putting entries($ORACLE_SID:$ORACLE_HOME:) for all instances in /etc/oratab with some twik, don't follow $ORACLE_SID variable, instead you can hard code SID name.
Please refer following URL for the example:
https://www.linuxquestions.org/questions/linux-software-2/start%7Cstop-multiple-oracle-databases-in-the-same-oracle-server-422050/

How to set package variable value in script component in SSIS

I have package variable (TableName), its value is set by for each loop container.
For instance TableName = sales set by for each loop after looping through informationschema.tables then I want to use TableName's value in dataflow for this I am using script component.
When I use script component to read TableName's value in script-file I cannot see variable any idea why??
I am using script component as source and TableName is in readonlyvariables.
Please help as I am new to SSIS.
On the Variable Mappings page of the Foreach Loop Editor, assign variables to each item of data that is returned by a single enumerated item. For example, a Foreach File enumerator returns only a file name at Index 0 and therefore requires only one variable mapping, whereas an enumerator that returns several columns of data in each row requires you to map a different variable to each column that you want to use in the Script task. +
After you have mapped enumerated items to variables, then you must add the mapped variables to the ReadOnlyVariables property on the Script page of the Script Task Editor to make them available to your script
For more details pls chk the below link
https://learn.microsoft.com/en-us/sql/integration-services/extending-packages-scripting/task/using-variables-in-the-script-task
https://social.technet.microsoft.com/wiki/contents/articles/22194.use-ssis-variables-and-parameters-in-a-script-task.aspx
Please use the following Microsoft Documentation link - it describes differences between Script Task and Script Component, and gives small code samples, specifically on using Variables.
as per this I need to use this.variables.myvariable
Thanks everyone.

OdiOSCommand assign variable

I have OdiOSCommand with command :
OdiOSCommand "-ERR_FILE=/home/oracle/jmt.err" "-WORKING_DIR=#PROJECT_DIR" "-SYNCHRONOUS=YES" "-CAPTURE_OUT_STREAM=ON_ERROR[NONE]" "-CAPTURE_ERR_STREAM=ON_ERROR[NONE]"
#TEMP = "hello world !"
But this way of assigning doesn't work.
The same problem is in echo "something" > #TEMP . This won't do anything.
#TEMP still contains only default value.
Do I need special syntax to manipulate ODI Variables in commands ?
Could you give me example how can I assign value to ODI variable ?
Thank you very much.
No other ways to change an ODI variable except two possibilities:
use Variable step with type Refresh Variable
use Variable step with type Set Variable
Drag and drop Variable into a package and choose proper type on General tab in Properties window.
If you are looking for more flexible mechanism for storing values in the memory during the session, you may use Java BeanShell substitutions. Anywehere you can write
<#TEMP="Hello world!"#>
This substitution will disappear on execution, but TEMP variable will keep assigned value while session is running. Somewhere in further steps you can write
<#=TEMP#>
And now the substitution is replaced by current value of the variable. You may use such constructions in ODI variable assignment or refreshment as well.

How to modify the variable in SSIS?

I have a simple String variable with the following value: "C:\Test.txt".
Now I would like to edit the variable to point to a different file.
I cannot find a way to do that. I can change the Name, Data Type, but not the value itself!
Do I need to delete the variable and create the new one?
Update: The problem was caused by "ReadOnly" property set to "True". For typical scenarios, see the accepted answer below.
As #Yuck and #devarc have noted, there are two different and distinct values a Variable holds. The Design-time value is the value you assign when the variable is first created. In your case, the variable holds C:\Test.txt as the design-time value. Everytime you open the package, it would show C:\Test.txt until you change it in the
To make the value of a variable change while the package is running, your options are either to set the value or calculate it. Here I have created a package-level variable CurrentFile with the value of C:\Test.txt
One thing that often trips people up is that they have correctly changed the run-time value but when they run it in BIDS, they see the "old" value. The value displayed in the Variables window does not change during package execution.
During package execution, my Variables window still shows the design-time value (C:\Test.txt) but the true value is reflected in the Locals window (C:\Test2.txt)
Setting a value
The value of most anything in SSIS can be established at run-time through a set of verbose command-line options or through configuration sources. The biggest difference in my mind is that this approach is that the value will always be the value for the entire lifetime of package execution. Sequential or parallel invocations of a package can change that value but for that execution the value would remain constant (barring an explicit modification of the value.
/SET
Command-line execution (dtexec.exe), right clicking on a package and running from the filesystem (dtexecUI.exe) or creating a SQL Agent job step of SQL Server Integration Services all allow for providing a run-time value through the SET command. Using the above variable, the following command would set the run-time value to C:\Test2.txt
dtexec /file C:\Generated.dtsx /set \Package.Variables[User::CurrentFile].Properties[Value];"C:\Test2.txt"
Configuration
SSIS offers an option to create configuration sources to provide run-time values to packages. The article I linked to above does a much better job describing the pros and cons of the configuration options than I will do here. I will say that I typically use both - my SET command configures a connection manager which is then used by the package to find the "full" set of package configurations.
Calculating a value
There are a variety of tasks in SSIS that can change the value of a variable as well as the use of Expressions to change a value. I see these as things that operate on value whilst the package is in flight.
Tasks
A Script Task is one of the most commonly used mechanisms for those starting out but I find other tools in the SSIS toolkit usually better suited for changing variable values.
Foreach Loop Container and Execute SQL Task are two of the other big Tasks you should look at for assignment of a variable value.
Expressions
Expressions are the most glorious candy in the SSIS toolbox. Most every "thing" in SSIS exposes properties for configuration. That's helpful, but using assigning an expression to build those properties is outstanding.
For example, imagine 3 variables RootFolder, FileName and ComputedCurrentFile with values of C:\, File2.txt and empty string. On the Properties window for ComputedCurrentFile we'd change the value for EvaluateAsExpression from False to True and then use an expression like #[User::RootFolder]+ "\\" +#[User::FileName] That simply concatenates the value the first two variables together. This can be helpful if the file name for processing was standard but the source folder changed often. Or if we're talking about output, it's common to use expressions to build an output file name using the date and possibly time of when the package is running.
Finally, there is nothing that prevents a mixing and matching of these approaches. I typically use a configuration to point a file enumerator at the correct starting folder and then use calculated values to identify the current file for processing.
If you want to change it in designer just right click on free space and --> Variables.
But if you want to change it at runtime I suggest you to:
create script task
choose language
add your variable to ReadWriteVariables.
Edit script.
For example in VB:
Dts.Variables("myVariable").Value = #"C:\Test2.txt";
Dts.TaskResult = ScriptResults.Success
Found an easy way to handle this. Remove the Variable from Expression which will enable Value Box to edit. Once it is edited, add the Variable back in the Expression should get the updated value. Hope this helps.
I was also facing the same issue like you where once the variable is declared and define (for eg:var1=text1.csv)in SSIS Variable window I was not able to update the variable value(for eg: var1=text2.csv) in SSIS Variable Window by clicking on the variable value field.
Applied below fix:-
I noticed that I was using var1 variable as a Expression by using expression builder so to update the value(for eg:-var1=text2.csv) I used expression builder window.once you done using the expression builder,you can see the text2.csv is got mapped to var1.

Resources