SOAP UI How to pass Teardown script "Pass" or "Fail" status to Octopus to fail a Deployment? - powershell

I am trying to have a status like failed or pass to be passed to Octopus to fail or pass a deployment.
I have three different projects, one project per product. Each of these tests are run today on the server using batch scripts. I am trying to work on a solution using powershell script, which will invoke these tests as batch and if the test results fail pass a variable and value back to Octopus to fail our deployment. We do not want our code to deploy in stage if tests fail.
I have bunch of scripts I am trying, like get Exitcode, but nothing seems to be working. I have the Scripts working if I kick off the .ps1 on the server. But I need the ability to pass fail or pass status to Octopus. can someone please help?

Related

How can i send values to a Jenkins script?

I have a Jenkins job and in that job the first thing that runs is a powershell script that I want to capture user inputs values and set them as global variables that are used through out the Jenkins job.
Now i want the user to be able to put these values in from their machine and then run the job with these values ?
How can i do this ?
EDIT: In case anybody else finds this answer. Please see the comments below. This should not be used for credentials! As the communication can be secured by TLS, the credentials will still be visible in build logs etc.
You need to check the This project is parameterized checkbox in the settings of your job in Jenkins. Then define the name, type etc.
The given name is already accessible via standard syntax.
In shell script ${nameOfParam} or %nameOfParam (depending on your shell / os).
In pipelines they are also accessible via params.nameOfParam.
You can set these variables via GUI using Build with parameters or via API call http://<JENKINS_URL>/job/<JOB_NAME>/buildWithParameters/nameOfParam=foo
See also: https://www.baeldung.com/ops/jenkins-parameterized-builds
Only thing I quiet don't get from your question is, what you exactly want to do with the powershell script. A pipeline script in Jenkins is executed on a node, so if the job starts it should be running without any user interaction. To set values from the user input as global variables in a powershell script, you already need to have them available within the jenkins node, hence it's nonsense to set them in the powershell script because they are already available.

how pass email in jenkins in run time through Variable

I am facing below problem,Appreciate if any one help
I am having jenkin job which will trigger java jar contains code to read the email from excel and the same email to be passed in jenkins for sending email in username field.
Thanks
Did you take a look at parameterized jobs (If you want to manually trigger it)?
If, you want to read from excel and pass to another job please take a look at this.
I'm trying to understand your problem:
1. Jenkins to trigger emails to DevOps team that the deployment task results
2. Application to trigger emails that the application is being deployed successfully (Or any other scenarios you want to achieve, please indicate, and I will try to enhance this post)
If above is the case, you should try to utilize Jenkins to complete the full process: build, test, deploy and verify, then consolidate the results then send out via email
It's a clear cut that Jenkins for deployment and app for business
There are different ways to verify your application is deployed successfully depends on how you identify if app deployment is successful.
Jenkins can detect those signals, e.g. send a ping or curl to the application and verify the response
Now only Jenkins needs to know the list of emails address for the deployment results, you can use parameterized jobs as #Avneesh Srivastava mentioned

How to run a remote Powershell in VSTS release only if script exists?

In VSTS release management there is a nice remote Powershell task where we can run a script on the target machine. However I'd need a way to tell the release managment that only run this file if it exists, otherwise silently ignore that.
I know I can configure a task to not block the process in case of error, however in that case there still will be an exclamation mark in the log and the deployment will get the partial succeeded status. I'd like to avoid this and show success even if the file doesn't exist.
With this I need it to support kind of optional setup scripts for several deployed products.
There isn’t the setting or feature in VSTS to check whether the script file is existing or not.
The simple way is that, you can create another script to call target script.
Create another script (e.g. wapperScript.ps1) to call target script (can use parameter to accept the target script path) and add to source control
Add Windows Machine copy task to copy wapperScript.ps1 to target machine
Add Remote PowerShell task to run wapperScript.ps1
If you make your script more robust with a guard clause so that it can be called regardless of any given environmental condition. This keeps your pipeline less complicated. You can take action on the "file exists" leg and do a noop on the other. You can signal to the release process either way with log entries.

Teamcity interaction with powershell script

I have a powershell script that runs for ~30 minutes (waiting on various process' to finish). At the end, it writes a message to the event log, determining if the process was a success or failure. I plan on hosting this script on teamcity and want the build to fail, but don't know how to handle the interaction between the script and teamcity in order for this to happen.
I'm looking for a way to make a powershell script that is ran remotely to communicate to teamcity whether it was a failure or success. I've read up on a lot of the teamcity documentation and I'm still not sure how to start going about this.
You should probably consider using TeamCity Service Messages, or specifically Reporting Build Problems.
An example of how to emit a service message using PowerShell (assuming you're using the PowerShell build step):
Write-Output "##teamcity[buildStatus text='I am a successful build']"
or
Write-Output "##teamcity[buildProblem description='$powershell_error_message']"
where you can inject the captured powershell error message.
To intentionally fail a build in teamcity you should use "[Environment] :: Exit (1)" instead of "Exit 1".
More information can be obtained at the link below:
https://confluence.jetbrains.com/display/TCD9/PowerShell

Want to pass last successful Team City build date to a Powershell script as a parameter

I have a Team City build configuration that calls a powershell script via command line that executes a bunch of database scripts.
What I want to do is to pass a parameter to the command line that is the date of the last SUCCESSFUL build run for the configuration, so I can only execute the db scripts that have been modified since the last run.
I can't seem to find any way to do this. Has anyone ever done this?
You could use the TeamCity REST API to get a list of last successful execution for your specific build. Then knowing the last successful build you can pull the date from the XML.
See here for API Details: http://confluence.jetbrains.com/display/TW/REST+API+Plugin#RESTAPIPlugin-BuildLocator