I am looking to implement a flag to make sure no one tiggers a job by mistake.
I have added a parameter which prompts before the the job is triggerd.
An command line build step is created with the following script:
IF %ConfirmationCheck% == "false" exit 1;
No matter what setting the confirmation box has, it always starts the rest of the steps.
Anyone an idea?
Thx
I'm using powershell to do the same thing
if ("%ConfirmPrompt%" -eq "false")
{
Write-Host "Error: Confirmation checkbox was not checked"
exit 1
}
Make sure that you edit the parameter and set the un/checked value, mine are set to false/true respectively.
Related
I would like to be able to add items to the logs displayed during VSTS builds and releases:
I've looked at this page and written the following test powershell script
$guid = $env:taskGuid
write-host "##vso[task.logdetail id=$guid;name=project1;type=build;order=1]create new timeline record"
# write-host "##vso[task.logdetail id=new guid;parentid=exist timeline record guid;name=project1;type=build;order=1]create new nested timeline record"
write-host "##vso[task.logdetail id=$guid;progress=50;state=InProgress;]update timeline record"
write-host "##vso[task.logdetail id=$guid;state=Completed;result=Succeeded]complete timeline record"
I was hoping to see additional entries in the log but I see no difference at all, not even the write-host statements appearing.
So I have 2 questions
What should I see from my sample script above?
Is it possible to get
additional entries in that log shown in the initial screenshot
without actually adding additional tasks?
The syntax you're using is designed to show in the timeline which doesn't appear to be used in the new build layout yet (see here to disable preview of new build output). If you use the old build output, select the step for the powershell script you're executing and then select time line, you will then see your step (which in my case is ssloan) being logged by the logger. . See here for a better run down of the various build steps than I could give.
For just outputting the the logs you can use a variety of writers provided in PowerShell utilities Write-Host should be sufficient so long as you always have a host to write to. These will then appear in your logs
I'm not sure if this is the correct page for this question but I'm having a hard time getting Dataloop to properly display a widget based on my Powershell script's exit code.
I've just began playing with Dataloop monitoring so I may be going about this all wrong, but as far as I can tell from their documentation, they use the same error code system as Nagios and that those error codes map to a .status metric within Dataloop which you can use for displaying widgets.
As a test, I created the following Powershell script:
if (Test-path c:\scripts02) {
Write-Host "I found the directory!"
exit 0
}
else {
Write-Host "I could not find the directory!"
exit 2
}
When I run the plugin test through the Dataloop site, this prints out the "I could not find the directory!" message along with the correct exit code of 2. When I change the path it's testing to an existing directory, it does exit with 0 and the correct output message. Everything seems to work as expected before until I move to the next part.
Inside Dataloop, I'd attempt to add a widget, set the source to one of my agents, select the "status" metric for my test plugin (the powershell script). The widget just appears with a gray screen when it should be green since the directory path does exist...
Has anyone had success with this? I checked out their documentation and tried the steps outlined there but have had no success.
For anyone who's interested, this is actually a bug in the dataloop agent v1.1. Updated to v1.3 and code executes properly and reports the correct exit code.
On a side note, I had to use the function below to get dataloop to report properly as well instead of the "exit [int]" in my original code above:
function ExitWithCode {
param($exitcode)
$host.SetShouldExit($exitcode)
exit
}
I am using Selenium IDE GotoIf command, if my condition is true, then selenium executes the label that I specified. In my case, I would like my test to break if the condition is true, without going to a label, I would like my test script to break immediately if my condition is true, without being redirected to a label. I think that what I would need is an IF command instead of a GOIF command. I would like my test to behave like this:
IF CONDITION==TRUE
TEST BREAK
ELSE KEEP EXECUTING
Is there any command to make that happen? I would like the execution to keep going only in case my condition is false and I would like my test case to break if my condition is true, of course since the test case would break, the execution would stop at that point!
Also, is there a command to make a test case explicitly break in Selenium IDE? I would like to voluntarily make my test case break, is there any command for that?
I answered a similar question before albeith in a defrent way.
To force Selenium to end with an error message you have to actualy cause an error on purpose. Truthfully I would be using...
gotoIf / condition is false / Variableiffalse
click / Errormessage of my choice / (leave value field empty)
label / Variableiffalse / (leave value field empty)
Test continue up to the end
The failed click command will automaticaly end the test and post the target as your error message. I hope this was useful
your error message should appear as something similar to [error] Element message I put in target not found
This is the first time I'm encountering GetLayoutObjectAttribute and I am having serious issues with it. My variable $web won't set. I think it's because PD_WebV isn't the right object name to refer to, but I don't know how to find the right object name. I can't find the objects name when I hit Edit Layout, so does anyone know how to find an layout objects name?
Loop
Pause/Resume Script [Duration (seconds): 1]
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
If[$Web="done"]
#execute if statements
After Edit:
After some troubleshooting, I found out that PD_WebV is the right object name to refer and it's refered to correctly, so my new question is why doesn't the script go to the line If[$Web="done"] and how could I fix it? Ss my If statement not evaluating something it should be? Is my $web variable never set to done or is the issue something completely different? Would the problem possibly have to do with my WebDirect sharing settings? Any guidance would help. Thanks.
After, After Edit:
So now that my application is getting past Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")], the variable $web only equals <HTML></HTML>. Does anyone know a way, without using javascript, to test the inside of the html tags?
Also, I printed the bounds of the webViewer PD_WebV that I can't locate on the layout but am referring to in the script. The bounds that are printed are different each time I run the script. Is the usual or unusual? My source is also about:blank so it doesn't look like I'm sourcing from a URL
Is my $web variable never set to done or is the issue something
completely different?
If you're doing:
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
then the only time
$Web="done"
will return true is when the web page loaded into your web viewer contains exactly the string "done" (in practical terms, that's never).
I have already suggested in a comment that you test for:
PatternCount ( $webpage ; "</html>" )
This is assuming you want the subsequent steps to execute only after the page has finished loading. The entire script would look something like this:
Loop
Pause/Resume Script [Duration (seconds): 1]
Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
Exit Loop If [ PatternCount ( $webpage ; "</html>" ) ]
End Loop
# execute statements
You might also want to add a counter to the loop and exit the script after n trials.
Ah, I reread your question.
To set the object name for your webviewer so that the GetLayoutObjectAttribute function works you need to set it in the Name field in the inspector when you have the webviewer selected.
e.g.:
After that your variable should populate.
Be aware
What it will populate with will be all of the html from the browser, i.e. not a boolean true/false liek your conditional suggests.
I'm not sure exactly what you're trying to accomplish, but to be able to determine a result from your web viewer you'll need to either parse the HTML to see if it's content contains what you're looking for or within the code you're setting the webviewer with, fire a javascript function that calls back to the FileMaker file using a FileMaker url.
As the first step in a build configuration I am trying to dynamically change a parameter and use it in the subsequent steps. Reading online, it seems that the way to do this is to call ##teamcity[setParameter. But this doesn't seem to be working. It doesn't even change the value in the same step.
For example, I have created a test parameter and set it's default value to '1'. Inside a powershell script, I tried to change it to 2, as shown below.
But the output remains unchanged as can be seen below
I am currently using TeamCity 8.0.3 (build 27540). What am I doing wrong?
EDIT: I think the problem might be the command you're using to set the parameter. Try:
Write-Host "##teamcity[setParameter name='TestParameter' value='2']"
--
We've experienced the same behavior. The key here is 'subsequent steps.' You must modify the parameter in a separate build step that is run before the step in which you want to use the new parameter.
It's my understanding that all parameters in a build step are evaluated immediately before the execution of that step. The tokens will be replaced with the unmodified values of those parameters. Thus, what actually gets executed by the build agent is:
Write-Host "TestParameter value is 1"
Write-Host "##teamcity[setParameter name='TestParameter' value='2']"
Write-Host "TestParameter value is 1"