Is there a way to run command lines asynchronously in Azure-DevOps Build Pipeline? - api

I'm setting up an Azure-DevOps pipeline in which I want to include automated tests via the Newman CLI.
Imagine a pipeline like this.
Build Project
Copy build to test folder
Run the application => (API-Server)
Run Newman
Kill API Server Process
On Success Copy Build to another folder.
My Problem is that my server application is in a waiting state after it's initialization.
The next Task in my build pipeline won't start.
Is there a way to run multiple command lines asynchronously in Azure-DevOps?
Starting the process in via "start" won't work since it throws me an
ERROR: Input redirection is not supported, exiting the process immediately.
start "%TESTDIR%\foo\bar.exe"
timeout 10

Related

gitlab: Is there a way to http access an artifact during a job, rather than after?

I'm trying to run a pipeline with two stages. The first stage creates a zip file and the second stage executes a http curl POST for that file. If the curl succeeds, the pipeline is completed.
The problem is that gitlab only exposes the zip file AFTER the pipeline has completed - which means the zip file from the previous pipeline gets sent instead.
I've tried using artifacts and dependencies, but it seems the http url is only exposed for completed pipelines. I tried using the url of the specific job that executed the build stage, but it didn't work either.
Does anyone know how to access an artifact by URL, before pipeline completion?
i was unable to find a way to access the artifact remotely before the pipeline had completed. sad face.
i have a workaround though - i moved the deploy stage to a separate pipeline. so the first pipeline just executes the build (generating the artifacts) and then triggers the second pipeline. the second pipeline is then able to access the artifacts of the first pipeline and it just executes a deploy stage. happy face.

can't trigger a test of some appllication via Jenkins job

I am a beginner at the field of Devops.
I have created a simple web application (jsp), using 3 Jenkins jobs to store the code in GIT, to deploy the this app into Tomcat, and also to site-monitor this app (respectively).
Now, I have been trying - with no success -to automate a simple test with 2 verifications of my app functionality, using Selenium IDE and triggering it via Jenkins job (the fourth one in my project).
In order to perform it , I created the following job on Jenkins, with the needed plugin added (which is SeleniumHQ htmlsuite Run).
Here is the job:
https://i.stack.imgur.com/6Pm6a.png
The job running has failed,giving the following error which I cant handle.
When I run it, I get the following error :
https://i.stack.imgur.com/hXGmI.png
Any help would be very appreciated
Just tick Delete workspace before build starts box under Build Environment stanza
If you don't have the option in your Jenkins job configuration - make sure that Workspace Cleanup Plugin is installed
If you're running your Selenium tests via Jenkins Pipeline - all you need to do is to put cleanWS() directive somewhere in your pipeline code or Jenkinsfile

TeamCity - The process cannot access the file * because it is being used by another process

I'm using TeamCity to build and run my MSTest project.
One job is responsible for building the project, once it has finished it triggers a second job responsible for running the compiled project using MSTest.
The problem is that when the second job is triggered almost immediately the following error is displayed and the job fails:
Starting: C:\...\JetBrains.BuildServer.NUnitLauncher.exe
...
...
...
The process cannot acces the file 'C:\BuildAgent\work\{identifier}' because it is being used by another process.
It seems that the job fails even before MSTest is invoked.

Start program via ssh in Jenkins and using it in Jenkins build

Hello people.
I'm using Jenkins as CI server and I need to run some performance test using Jmeter. I've setup the plugin and configured my workspace and everything works ok, but I have to do some steps manually and I want a bit more of "automation".
Currently i have some small programs in a remote server. These programs make some specific validations, for instance (just to explain): validates e-mail addresses, phone numbers, etc.
So, before I run the build in jenkins, I have to manually start the program (file.sh) I want:
I have to use putty (or any othe ssh client) to conect to the server and then run, for instance, the command
./email_validation.sh
And the Jmeter test runs in a correct way, and when the test is done I have to manually "shut down" the program I started. But what I want is trying to start the program I need in Jenkins configuration (not manually outside Jenkins, but in "execute shell" or "execute remote shell using ssh" build step).
I have tried to start it, but it get stuck, because when Jenkins build finds the command
./email_validation.sh
the build stops, it waits for the command to finish and then it will continue the other build steps, but obviously, I need this step not to finish until the test is executed.
Is there a way to achieve this? Thanks
Run your command as a background process by adding the & symbol at the end of the command and use the nohup command in case the parent process gets a hangup signal, e.g.
nohup /path/to/email_validation.sh &
If the script produces any output, it will go by default to the file nohup.out in the current directory when the script was launched.
You can kill the process at the end of the build by running:
pkill email_validation.sh

groovy (java): exec() do not detach from process (Intellij IDEA vs Maven+TestNG)

I have Groovy Maven2 test project with TestNG and Surefire plugin enabled.
I want to launch external process (*.cmd file which start some *.exe file) in last test method, finish my tests and left process running after tests.
I tried the following codes to do it:
1 attempt
def builder = new ProcessBuilder('cmd','/c <name>.cmd')
builder.directory( ( new File( <path_to_working_directory> ) ) )
builder.start()
2 attempt (with and without start cmd option)
Runtime.getRuntime().exec( "cmd /c start <name>.cmd", null , ( new File( <path_to_working_directory> ) ) )
3 attempt
( new AntBuilder() ).exec(
dir: "<path_to_working_directory>",
executable: "<name>.cmd"
)
Where .cmd is:
set path=<path_to_execFile>;%path%
start <execFileName>.exe
When I launch each of these codes from Intellij IDEA via 'Run' functionality (Alt+Shift+F10) codes execute successfully, process started and run after test finishes.
When I launch each of these codes both from Intellij IDEA Maven task, clean Maven installation (and even Maven task from Jenkins) process started successfully but test remains running. I need to kill it manually. When I kill test process (Maven process) manually my launched external process continue to work as I expect.
This hung test process is my headache for the moment.
I looked through a lot of materials but didn't find any root cause, fix and even workaround for this issue. I see that all my attempts (perhaps, except of AntBuilder()) create deattached processes. I suppose that this can be connected with JVM settings. But I coudnl't find to which one.
Also, I tried
"full command to run my cmd".execute()
but it didn't help me too.
Could you please help me resolve the issue?
Thanks In Advance!
So, I do not see any answers for my issue here. But I have some updates.
I found that I can use PsExec tool instead of direct cmd calling:
def builder = new ProcessBuilder( 'psexec', 'cmd', '/c', '<name>.cmd' )
builder.directory( ( new File( <path_to_working_directory> ) ) )
builder.start()
And this code works fine when I launch it from clean Maven only (not from Jenkins): process started, Maven task completes successfully, the process continues to run.
But during execute this code as part of some Maven2 Jenkins task I faced to issue again: psexec started but Jenkins task is running and my process does not started before I terminate Jenkins task manually.
To avoid this issue I created simple additional Groovy service script I launch in listen mode (and Writing a TCP Server) on target machine manually during initial machine preparation. This script is running on machine always.
I send to this listener name of command file to execute from my test I launch from Jenkins and it executes all cmds successfully: processes start, Jenkins task completes successfully, processes continue to run. I use processbuilder inside this listener.
For name sending I use simple socket (Writing a TCP Client)
Also, I found how to detach child from process tree on win32?. But for me system my way looks more Groovy I think.