I create a custom mediator in apache synapse to invoke some system command such as java -jar, execute shell script, etc.. But i have no luck to this, i tried these codes :
Process process =runtime.exec("touch /opt/FILE.txt");
and
Process p = runtime.exec(new String[]{"java","-jar","/opt/MyMediator.jar"});
both of them were runnable when i create the jar and run the jar manually, but when i deploy it to the synapse lib, it wont work. So can anybody tell me how to do this properly?
Thanks,
Related
I'm new to Gitlab (and YML files, and just about everything else in this project ...), and want to add some script to the build pipeline to automate release file generation.
I added a few script lines to the branch's release section in gitlab-ci.yml, and can see they're generally doing what I want in the console output to the Gitlab UI. But, after a bit of head scratching I now realise the build itself is executed within a docker instance, which explains why I can't see the release file on the Gitlab host machine.
Is there a way of executing script from the YML file on the Gitlab host, as opposed to within the build container?
It depends on the executor type of the Gitlab Runner where the scripts are executed.
If the jobs are executed on a runner with a docker executor, each job will be run in a new container.
If the jobs are executed on a runner with a Shell executor the jobs will be executed directly on the runner machine.
BTW, it is not advised to have your runners on the same machine where you host your Gitlab server. Especially, runners with Shell executor. It compromises resiliency and scalability. A CI/CD job could break the entire host and make your gitlab server unavailable.
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
when we execute the selenium scripts using testng.xml file in jenkin server. we are not able to view the testng-failed.xml file . Could you please help us to understand why it is not showing the file . when we execute same build using eclipse id we are able to view it but it is not creating when we execute using jenkins
Hi All I am tying to setup a RestAPI pipeline in aws codebuild. I have custom Newman docker. I have a build command that will failure but I want to execute the rest of the commands as well. but shell stops executions other commands when the Newman command fails. how to execute other commands in yml file.
One simple way would be:
You can create a custom shell script (mycommand.sh) with your command that can cause error inside a try catch statement (so that it will not result in an error)
In your Code build's yml file under commands section, just execute the ./mycommand.sh
Source:
https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-cmd.html
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.