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

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

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.

Can I re-run a Power Automate flow instance from history?

Is there any way to find and re-run an earlier instance of a Power Automate workflow programmatically?
I can do this manually: download the .csv file containing the instances, search in the Trigger output column the one I want, get the id, copy-paste the run URL, and click resubmit.
I tried with Power Automate itself:
The built-in Flow Management connector supports only to find a specific flow by name, and does not even go to the history.
PowerShell:
Installed the PowerApps module, I can list the instances with
Get-FlowRun -FlowName {flow name}
But I don't see the same properties as in the exported .csv file, and there's also no Run-Flow command that would let me run it.
So, I am a little stuck here; could someone please help me out?
We cannot programmatically resubmit the Flow run from the history with PowerShell or by any other api method yet.
But can avoid some manual work by using workflow function in a Flow compose step, we can automate the composition of Flow history run url. Read more
https://xxx.flow.microsoft.com/manage/environments/07aa1562-fea6-4583-8d76-9a8e67cbf298/flows/141e89fb-af2d-47ac-be25-f9176e64e9a0/runs/08586722084717816659969428791CU12?backUrl=%2Fflows%2F141e89fb-af2d-47ac-be25-f9176e64e9a0%2Fdetails&runStatus=Failed
There are 3 guids that I need to find aso that I can build up the flow history url.
The first guid is my environmentName (07aa1562-fea6-4583-8d76-9a8e67cbf298), then I’ve got the flow name ( 141e89fb-af2d-47ac-be25-f9176e64e9a0) and finally the run (08586722084717816659969428791CU12).
There is a cmdlet from Microsoft 365 CLI to resubmit a flow run
m365 flow run resubmit --environment flowEnvironmentID --flow flowGUID --name flowRunID –confirm
You can also resubmit a flow run using Power Automate REST API
https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/{FlowEnvironment}/flows/{FlowGUID}/triggers/manual/histories/{FlowRunID}/resubmit?api-version=2016-11-01
For the Power Automate REST API, you will have to pass an authorization token.
For more information, go through the following post
https://ashiqf.com/2021/05/09/resubmit-your-failed-power-automate-flow-runs-automatically-using-m365-cli-and-rest-api/

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

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?

Is it possible to execute TF history command from a script build task?

I am setting up new builds in TFS 2018 on premise. We need to track the changesets used for our builds.
I have a PowerShell script as a build task that executes TF.exe history command to get the info.
This script runs as long as I execute it from my session but it fails from the build process with a "you are not authorized to access " message. I realize I can add my login info to the command and it will work as expected.
Is there a way to specify that it run as the local system? The user is runs under now is "machinename$"
You could do it by running
tf /loginType:OAuth /login:.,$env:SYSTEM_ACCESSTOKEN
But you have to allow access to token on the build agent phase.
Edit your build definition, click on the options view. There you will find the field to allow token access.

Create QlikView task through command line

I want to be able to create a task for qvw files with a command (cmd, powershell, etc), just as you would through the QlikView Management Console. We would like to be able to automate some of the task creation remotely which would require this functionality.
I know that there are arguments that can be passed through the qv.exe to reload the document, but I want to actually create a task through a command line. Is this possible?
Don't think that this is possible out of the box. You can control QV server through QlikView Management Services API. But for this reason you need to build a .net command line app that will do whatever you want.
If you are interested follow this link for more info.