On Octopus deploy, how do I run process step if any of previous steps has failed - octopus-deploy

I have a step that will send a message to Microsoft Teams when the deployment is successful, and I want to add another step that will send a message if there is an error in the deployment and one of the steps fails.
I've tried setting a condition on the step to Variable: only run when the variable expression is true with the expression being #{if Octopus.Deployment.Error != 0}#{/if}
I was under the impression that if a step fails the system variable Octopus.Deployment.Error will be different than 0
the version of Octopus Deploy that I am using is 3.11.11

Conditional logic isn't supported within the #{if} syntax. The variable will be evaluated and if it evaluates to a true value, then the value inside of #{if}#{/if} will be used for the condition.
You can use this expression #{Octopus.Deployment.Error} for the run condition. If an error has been set, it will evaluate to true and the step will run. If there has not been an error, it will evaluate to false and the step will not run.
I hope that helps!

Related

What is the easiest way to make Azure pipeline stage fail for debugging purposes

I would like to make a given stage fail to test my conditions
- stage: EnvironmentDeploy
condition: and(succeeded()...)
is it possible to make - stage to fail purposefully?
The easiest way I can think of is adding a job with a PowerShell script, and using the throw keyword to exit the script with an error:
stages:
- stage: StageToFail
jobs:
- job: JobToFail
steps:
- pwsh: throw "Throwing error for debugging purposes"
I assume you don't want this fail to happen consistently as that would make deployment impossible. Assuming it's a one-off thing, why not try to upload code with compile errors so the build fails or - if your code base has them and your pipeline checks them as a prerequisite for deployment - add a unit test that fails.

TeamCity Failure Condition for ESLint warnings increases does not stop build (using eslint-teamcity)

I have a TeamCity step that runs this script:
"teamcity:eslint": eslint src/**/*.{ts,tsx} --format ./node_modules/eslint-teamcity/index.js --max-warnings 0
It uses the eslint-teamcity to format the error/warnings linting result.
This is the package.json configuration:
"eslint-teamcity": {
"reporter": "inspections",
"report-name": "ESLint Violations",
"error-statistics-name": "ESLint Error Count",
"warning-statistics-name": "ESLint Warning Count"
},
I created a test "master" branch with 2 lint warnings and TeamCity "Inspections" shows them:
I have set this Failure Condition:
Now, to test it I created a branch with 3 or 4 lint warnings.
I commit it but the build does not fail despite the number of warnings has increased:
I expect the build to fail.
I've no idea how and where TeamCity store the "inspection" warnings counter for that Failure Condition, so I have no idea how to investigate this unexpected behaviour.
Or, I missed some step/configuration?
TeamCity 2019.2
Failuer Condition code:
failOnMetricChange {
metric = BuildFailureOnMetric.MetricType.INSPECTION_WARN_COUNT
units = BuildFailureOnMetric.MetricUnit.DEFAULT_UNIT
comparison = BuildFailureOnMetric.MetricComparison.MORE
compareTo = build {
buildRule = buildWithTag {
tag = "test-master"
}
}
stopBuildOnFailure = true
}
I took as example of the Failure Condition another TeamCity project that was checking the tests coverage.
I gave for grant (didn't pay attention) that tag: master in the Failure Condition was actually looking at "master" branch for reference.
At the end of the log (many other steps after my try) I finally saw this warning:
Cannot find Latest build with tag: 'test-master', branch filter: feature/test-warnings to calculate metric 'number of inspection warnings' for branch feature/test-warnings
Still not sure if this means also that the comparison cannot be done on another branch, but this answer my question about Failure Condition not working as expected.

Failed test in protractor stops the execution for rest test cases

I am running the protractor Suite (spec file having multiple test cases), If any test case fails, protractor does not continue with the next test case execution and all the rest of test cases also fail.
EXPECTED BEHAVIOR:
Upon failure on any test case, protractor should continue with next test case execution.
I used "Protractor-Fail-Fast" Npm package to stop the rest test case execution if any test case fail. But ideally I am not looking for the same.
But this will not help me!
Just for reference: In Visual Studio MS test, If I created ordered test (same as Spec file in protractor having multiple test cases) and then set test setting like "continue on failure", ordered test execution will continue even if some test case failed.
I am looking for a similar test setting or any solution for protractor.
If you dont't want to stop all tests run just stop using Protractor-Fail-Fast library? Protractor tests run till the end by default even if some of the tests are failed.
set ignoreUncaughtExceptions: true in config file as following:
/**
* If set, Protractor will ignore uncaught exceptions instead of exiting
* without an error code. The exceptions will still be logged as warnings.
*/
ignoreUncaughtExceptions?: boolean;
you can get above description from here
export.config = {
...
ignoreUncaughtExceptions: true
}

Issue using User defined parameter in Build Feature teamcity?

I have template which have two build steps:
Maven
Command line
Command line steps sets current datetime in variable which i want to use in Build Feature.
I am getting proper Current datetime as follows via Command Line step:
#!/bin/bash
export current_build_date_format="+%%d%%m%%Y_%%H%%M%%S"
export current_build_date="$(date $current_build_date_format)"
##teamcity[setParameter name='current_build_date' value='$current_build_date']
When i am trying to refer it in Build Feature, its not able to identify parameter via "%current_build_date%"
It shows paramter as undefined in Configuration Parameter section
Anything missing? I have defined that parameter via command line, how will teamcity features use that
Parameter error:
Error while reading user defined parameter first:
Initialization
[05:42:27][Initialization] - Build Details Validator
[05:42:27][ Build Details Validator] Error: Conversion = 'm'
[05:42:27][Initialization] Build validation failed
You need to echo TeamCity service message to let TeamCity parse and use it, e.g.:
echo "##teamcity[setParameter name='current_build_date' value='$current_build_date']"

Rerun a specific test once on failure

I have a flapping test in my test suite - it fails once out of every hundred runs or so.
However, this is kind of expected behavior as it's a test for a algorithm that runs a lot of things and returns a result - every once in while a result just can't be found. If I run the test suite again, everything is green.
Is there a way to re-run this one particular test if it fails and use the results of the rerun?
For example, 99% of the time this test passes. In the event that it fails, it should automatically be re-run without triggering a failure. If that re-run test fails, it should be reported as a normal failing test.
I'm thinking something like this, which is used to stop the test suite on failure:
class << MiniTest::Unit.runner; self; end.class_eval do
def puke(suite, test, e)
super(suite, test, e)
if ENV['FAIL_FAST'] && !e.kind_of?(MiniTest::Skip)
turn_reporter.io.puts "****** Fail fast active for tests, exiting (environment variable FAIL_FAST exists)"
exit(1)
end
end
end
but instead of 'failing fast' it 're-runs' the failing test. The difference is that the above code has an environment variable set - so if any test fails, it 'pukes' - I would only want to put this 're-run' flag on one specific test.
Has anyone found a way to do this?

Resources