How do I set a secret value with build script interaction on team city? - teamcity

I know I can define a secret value like this in kotlin DSL on teamcity:
params {
password(
"env.MY_SECRET_VALUE",
"credentialsJSON:faf2d7c8-3565-452a-8cfe-a7a55a4f0f4c",
display = ParameterDisplay.HIDDEN
)
}
How do I achieve the same with build script interaction? I mean a command of the kind
##teamcity[setParameter name='env.MY_SECRET_VALUE' value='1234']
Is it possible at all? I was unable to find this use-case in this documentation, which is the most complete I've found until now on the topic.

The way I understand it, making this happen with build script interaction makes no sense, because I'd need to write a command like
echo "##teamcity[setParameter password='env.MY_SECRET_VALUE' value='1234']"
assuming such a command existed. That means TeamCity will display that line in the logs with the value not hidden, making it therefore pointless.

Related

Checking the result returned by a command, along with exit-status

Sorry I'm a little new to Ansible and don't quite understand playbooks completely, and was wondering if someone would be able to help me identify and fix my issue. I want to run a command which checks if a service is enabled, and returns "true" in stdout, and this is what I have so far.
Side note (incase the command seems confusing): The first parameter is the location of a binary that I must use, followed by the parameters I must provide the binary to receive my result.
command:
/opt/tableau/tableau_server/packages/customer-bin.123/tsm configuration get -k service.jmx_enabled:
exit-status: 0
stdout:
- "True"
Unfortunately this test case seems to be failing and produces the result: "stdout: patterns not found: [true]" and I have no idea what I'm doing wrong. If someone could look this over for me that would be awesome!
EDIT: The default_test.yml playbook is run by molecule when testing roles.
take a look here
https://linuxhint.com/print-command-output-ansible/
perhaps you want debug to output the result
Having investigated the issue further, I was able to uncover that Ansible STDOUT comparisons – using the method highlighted in the original question – is a case-sensitive process, and does not account for differences in capitalisation and casing. Instead it expects an exact match when aiming to identify the "pattern" that was being used. In my case, the execution of the command returned "true" and not "True", and so by simply modifying the expected-pattern I was able to resolve the issue. If the execution of this step is not dependent on a testing suite or CI/CD pipeline such as Atlassian Bamboo (or others), I do suggest taking a look into Andylondon's answer, which recommends registering the output of STDOUT to a variable, which can then be used to debug any issues.

Implicit variables are not defined in automation scripts

Upon creation of a automation script in IBM Control Desk / Maximo an array of implicit variables are created, according to the IBM docs:
Implicit variables are variables that you do not define. These
variables are automatically provided by the framework. Some implicit
variables are valid only when associated with a declared variable
while others are not associated with any other variables.
In addition to implicit variables, a Maximo® business object (MBO) is
also available to every script. You refer to the current business
object by using the mbo reserved word.
From these docs:
https://www.ibm.com/support/knowledgecenter/SSANHD_7.6.0/com.ibm.mbs.doc/autoscript/r_variables_automation_scripts.html
When trying to use mbo with the following code inside a newly created Automation Script with no launch point:
mboSet = mbo.getThisMboSet()
I get the following error message:
NameError: name 'mbo' is not defined
This seems strange to me as mbo is a implicit variable that should be accessible.
I am new to Maximo and don't have enough experience to debug this problem at this point. How would I acces the mbo variable and use it? Thanks in advance.
mbo represents a single psdi.mbo.Mbo from a single psdi.mbo.MboSet (see the JavaDocs), or synonymously a single row from a single table. The Launch Point is what chooses the record to send to your script as mbo.
If you run your automation script directly, via the Test button or by restoring the Execute button, which table and which row from that table should Maximo randomly choose to pass to your script as mbo? The answer to that rhetorical question is "none" -- Maximo should not randomly choose some record from some table but should not define mbo in such cases. Hence, the error is expected behaviour in the situation you presented.
If you want your script to be able to run directly as well as from a launch point, you can check if "mbo" not in locals(): and then set up mbo for yourself. I have dubbed such automation scripts as "On Demand Autoscripts", and I use them regularly. If you spend some quality time with the JavaDocs, you might get there, too!
You say it's a newly created Automation Script with no launch point? How did the script actually run then to get that error? Did you press the test button? If so, that's the problem. The test doesn't run the script in context (where those variables can exist). You will need to create a launch point to trigger your script, then you should see the implicit variables come into play.

Setting multiple values for Vim command -complete attribute

I am trying to enable command completion for a custom command that I am setting up for a plugin in the following manner:
command! -complete=shellcmd -nargs=* EScratch call s:ShellScratch(<f-args>)
I would like to enable complete options for shellcmd and file. However it seems that the complete attribute would only take 1 option.
To give a bit more context as to what I am trying to achieve: I am working on a plugin to create a simple scratch buffer. I would like to be able to run a shell command from the command mode and copy the output to the scratch buffer. I have been able to achieve all this but it would be much more productive to have auto completion similar to shell. The complete script can be viewed here https://github.com/ifthikhan/vimscratch/blob/master/plugin/vimscratch.vim. Any pointers will be highly appreciated.
Unfortunately, you can't. If you really need this, you have to either
define two separate commands, e.g. :ScratchShell and :ScratchFile, with the corresponding completions, or
use a -complete=custom[list] and provide your own complete function, where you have to re-implement both sources yourself. Filename completion actually is quite easily done with glob(); I'm not so sure about shell commands.

What exactly is going on in Proc::Background?

I am trying to write a script that automates other perl scripts. Essentially, I have a few scripts that rollup data for me and need to be run weekly. I also have a couple that need to be run on the weekend to check things and email me if there is a problem. I have the email worked out and everything but the automation. Judging by an internet search, it seems as though using Proc::Background is the way to go. I tried writing a very basic script to test it and can't quite figure it out. I am pretty new to Perl and have never automated anything before (other than through windows task scheduler), so I really don't understand what the code is saying.
My code:
use Proc::Background;
$command = "C:/strawberry/runDir/SendMail.pl";
my $proc1 = Proc::Background -> new($command);
I receive an error that says no executable program located at C:... Can someone explain to me what exactly the code (Proc::Background) is doing? I will then at least have a better idea of how to accomplish my task and debug in the future. Thanks.
I did notice on Proc::Background's documentation the following:
The Win32::Process module is always used to spawn background processes
on the Win32 platform. This module always takes a single string
argument containing the executable's name and any option arguments.
In addition, it requires that the absolute path to the executable is
also passed to it. If only a single argument is passed to new, then
it is split on whitespace into an array and the first element of the
split array is used at the executable's name. If multiple arguments
are passed to new, then the first element is used as the executable's
name.
So, it looks like it requires an executable, which a Perl script would not be, but "perl.exe" would be.
I typically specify the "perl.exe" in my Windows tasks as well:
C:\dwimperl\perl\bin\perl.exe "C:\Dropbox\Programming\Perl\mccabe.pl"

capturing what keys were used to launch vbscript

I have an application that has 'macro' capabilities. When I map some keys on the keyboard to perform the 'macro', I can also have it launch vbscript instead.
What i'd like to try and do is within my vbscript figure out what keys were used in order to launch the script. Is it posible to do this? Could there be a way in vbscript to figure out what keys were last touched on the keyboard and then I could apply my logic.
The purpose of doing this is to keep the code in a single .vb file instead of several seperate .vb script files(one for each keyboard mapping, possible 3-4). Obviously we are looking to just maintain 1 file instead of multiple files with essentially the same code in each one.
I am leaning towards the idea that this is not possible, but i figured this would be a worthy question for the masses of StackOverflow. Thanks for the help everyone!
What you are asking for is not possible.
Can you change your VBScript to accept parameters and then call it with a different parameter based on which hotkey was selected?
I agree with aphoria, the only way to make something like this possible is if your keyboard mapping software allows you to assign a script/command with parameters/arguments. For example if you used
c:\Temp\something.vbs
then you would change this to
%WINDIR%\system32\wscript.exe c:\temp\something.vbs "Ctrl-Alt-R"
Then in your vbscript code you could collect the argument using the wscript.Arguments object collection to do actions based on what argument/parameter was passed. See the following two links for more info:
http://msdn.microsoft.com/en-us/library/z2b05k8s(VS.85).aspx
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0915.mspx
The one possible approach you may use is to install keylogger and read its log in your VBScript.
For example save script start time in the very beginning of the script
StartTime = Timer()
and then read one log record of your keylogger before this time.

Resources