I have CICD running. How can I automate the steps to prepare a release locally? - scripting

I already have CICD in Jenkins automated for my team. A push to the master branch will test & deploy my team’s node app to npm. However the steps to prepare get a release are complicated and many, and right now just reside in a text file. I just copy those steps from the text document and paste them into a Unix command line to run them. I want to code something to automate/tool that release prep.
I need to run steps of commands, and pause to confirm.
I need to be able to quit at any step and resume at any step.
I need to alternate between performing steps for the computer and informational steps for displaying to people.
Nice to have:
It would be nice to have steps be relatively human readable in the code.
I would prefer to use someone else's to not roll my own.
I already know JavaScript, Bash, Make, yml
How can I best automate my pre-release steps?

You can just pass all the commands to the shell script like so in unix,
$ vi release.sh
#!/bin/bash
//Release commands here
I need to run steps of commands, and pause to confirm.
You can add the follow piece of code on the commands that you would like conformation before proceeding
echo "Do you want to continue?(yes/no)"
read input
if [ "$input" == "yes" ]
then
echo "continue"
fi
I need to be able to quit at any step and resume at any step.
I'm guessing you mean PAUSE and resume
when your shell script is running and you feel the urge to PAUSE you can use Crtl+Z to PAUSE the script and do whatever you want to do like run other scripts/process or go for a cup of coffee :)
To resume, type
$jobs -->List all jobs
[1]+ Stopped release
run fg(foreground) or bg(background)
Note: have to be in the same active shell for it to work
I need to alternate between performing steps for the computer and
informational steps for displaying to people
Add echo
echo "Going to copy the file from actual location to target location"
cp ACTUAL_LOC/file.txt TARGET_LOC/file.txt
It would be nice to have steps be relatively human readable in the
code.
This totally depends on how well you write the script file :)
I would prefer to use someone else's to not roll my own.
Do You mean rollback in sql or unix commands when a failure happens??

Related

How to write a SUMO scenario file?

I am trying to understand what files do I need to build a scenario in SUMO. So far I know how to use NetEdit to generate the network file (net.xml) and the route file which shows the routes of the vehicles (rou.xml). I would like to then determine the actions that my autonomous ego vehicle will make so that it makes specific movements (e.g.: overtaking or changing lanes) after driving for some time and this simulation scenario can be replayed on a simulator. I am not sure how to do this.
Now that you have the net and the route file you are ready to simulate. Depending on your sumo version you can probably start the simulation directly from netedit by choosing "Open in sumo-gui" from the edit menu (or press ctrl+t).
If you want to start a simulation without GUI from the command line, you can do sumo -n mynet.net.xml -r myroutes.rou.xml. You can also save a configuration this way by doing `sumo -n mynet.net.xml -r myroutes.rou.xml -C mycfg.sumocfg. Than you can double click the sumocfg to start the simulation.

Execute Unidata Process from the shell command lines?

Is it possible to execute the Unidata process from the Unix Command line??
If it's possible, can anyone please let me know how to??
I just want to add some Unidata Processes into the shell script and run it from the Unix
Cron job.
Unidata Process
Unix Command line
Yes! There are several approaches, depending on how your application is setup.
Just pipe the input to the udt process and let 'er rip
$cd /path/to/account
$echo "COUNT VOC" | udt
This will run synchronously, and you may have to also respond to any prompts your application puts up, unless it is checking to see if the session is connected to a tty. Check the LOGIN paragraph in VOC to see what runs at startup.
Same, but run async as a phantom
$cd /path/to/account
$udt PHANTOM COUNT VOC
This will return immediately, the commands will run in the background. Have to check the COMO/PH file for the output from the command. It's common for applications to skip or have a cut down startup process when run as a phantom (check for #USERTYPE)
If none of the above work because of the way your application is written, use something like expect to force the issue.
spawn udt
expect "ogin:"
send "rubbleb\r"
etc.
https://en.wikipedia.org/wiki/Expect for more info on expect

Start a Spring-Shell based application not interactive

Is it possible to start a specific command of a Spring-Shell app and then return/exit the shell after the command is finished? Further is it possible to expose the exit code (System.exit) of the app to the operating system shell?
For my purpose i will take advantage of the plugin mechanism and the CLI-Annotations of Spring-Shell. But in general there is no human interaction with the app, instead a job scheduler (UC4) will start the app and check the exit code to generate an email in case of an exit code not equal to 0. On the other hand for manual tests by our customer, there is also the need of tab completion, usage help etc.
This behavior is already built-in (although we considered removing it, or at least make it optional). I see now that it is useful :)
Simply invoke the shell with your (sole) command and the shell will spin up, execute the command, and quit. Also, the return code of the shell already indicates whether there was an error or not (tried with an inexistant command for example). Of course, if your custom commands do not properly indicate an error (i.e. print an error message but perform a normal return) this will not work. You should throw an exception instead.
The behavior is back.
Run spring-shell with #my-script, like so:
java -jar my-app.jar #my-script
Where my-script is a file with your commands:
my-command1 arg1 arg2
my-command2 arg1 arg2

Batch file doubts

I have a .bat file shown below in which I want to redirect the whole contents present in my IDE to some text file.
D:\WindRiver\wrenv.exe -p vxworks653-2.2.3 run
D:\WindRiver\wrenv.exe -p vxworks653-2.2.3>C:\ThreePartition\output.txt
PAUSE
I am able to just get some partial output i.e I am unable to get the errors which are thrown during compilation or building process.
Is this correct or Can anyone suggest any other way??
Thanks a lot
Maddy
You can try this:
D:\WindRiver\wrenv.exe -p vxworks653-2.2.3 > C:\ThreePartition\output.txt 2>&1
You can find a good explanation here. Basically you need to redirect both stdout AND stderr to your file.
Best regards.
Your batch is redirecting all messages from wrenv.exe that are sent to the standard output.
I never used WinRiver but usually IDEs manage the console internally and don't log any messages on the standard output/error stream.
It is maybe possible to set the output of the console of the IDE though. If it is, try to set it to the standard output.
I think you want to combine both those lines into one:
D:\WindRiver\wrenv.exe -p vxworks653-2.2.3 run >C:\ThreePartition\output.txt
OK, looking at your posts here, here and here, it seems you want to log the compilation process. The command for that will be something like (all on one line):
make ThreePartition.mak >C:\ThreePartition\output.txt
Assuming there's a file called ThreePartition.mak.
The command you've been using so far is designed to simply open an interface where you can type commands, which is why you get no output. If you want to log simulation, or a kernel build, there is a file called vxworks_cli_tools_users_guide_6.6.pdf which describes the command line interface, including vxprj in full detail.
Also, are you really using a nant script to call a .vbs to call a .bat to call wrenv.exe? I'm sure there's a simpler way to do that.

How can I put a process to background after its execution with broken CTRL+Z?

The question is special because some keys, such as CTRL+Z, stopped working.
I tried to put the process to background by typing in the order:
find /
CTRL+Z
bg
However, I can still see the stdout. The only difference to only doing the first step is that the command CTRL+Z does not work anymore. It is rather nasty when I have unsaved jobs and my harddrive is over 100GB. So
how can I put the process to background?
[Details]
I am using the fourth version of Bash on Mac.
[Crux Reply by Nicholas Riley]
The problem is really that I do not understand the "ramifications" of running process background. I cannot understand why the commnands, such as CTRL+Z, do not work to background processes. I was still able to kill the process in another shell with the command:
ps -ej | awk '! /grep/ && /find/ {print $2}' | xargs kill -9
^Z isn't working because the frontmost job is now the shell, and shells don't usually respond to SIGTSTP. (If you do really want to suspend a non-login shell, suspend usually works.)
The problem seems to be you misunderstand the ramifications of a job being in the background. Redirecting the job's standard output is unrelated.
In fact, it's unclear what you want to do. If you just want to stop find from running, then fg it and use ^C or ^\ (which by default send SIGINT and SIGQUIT respectively).
If you want to keep find running but suppress its further output, then the easiest solution I can think of is to use bg ; disown ; exit. That will stop the shell from killing its child process (find) and exit the shell; assuming it's at the top level of the Terminal window, you'll see a bit more output and find will keep running (but you'll have no way to interact with it).
I use disown.
find / & disown
exit # close the terminal and the command still runs
You can use disown after you ^Z as well:
find /
^Z
bg
disown
exit
disown is a bash builtin, I believe. Not sure about alternatives for other shells.
For further information, see my equivalent answer on Server Fault.
You can set the operation to a different key with stty on any UNIX-like system.
$ stty susp Q
will make Q your suspend key in place of CTRL-Z.
Backgrounding a process will not disconnect the output from the terminal device, that's why you're still seeing output and the output may well contain control characters which can stuff up your TTY settings (cating binary files is a good way to do that).
If you want the job to run in the background, do it right:
find / >/tmp/out 2>&1 &
then examine the /tmp/out file when it's finished.
I usually do this kind of thing with nohup. Like this:
nohup find / > /tmp/myresults.txt &
nohup makes sure that the process doesn't stop, even if the console goes away (like, you close the window or lose your SSH or whatever). The ">" sends output to a file rather than to the console, and "&" puts the job in the background.
I'll assume you're using a common variant of Linux or UNIX and possibly the bash shell. In which case:
CTRL-Z sends the SIGTSTP signal to the foreground process. You should be able to do the same thing with the kill command by specifying kill -s SIGTSTP [pid].
I know that in Ubuntu 9.04, you can start the process with a & after it to run it in the background. For example, "sudo gedit /boot/grub/menu.lst &" will start a text editor editing the GRUB config file in the background.
kill -STOP your_pid_here
from another console window?
http://tombuntu.com/index.php/2007/11/23/how-to-pause-a-linux-process/#comment-132413