Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 539
Kzqai Avatar asked Nov 08 '22 07:11

Kzqai


1 Answers

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??

like image 81
rohit thomas Avatar answered Nov 24 '22 09:11

rohit thomas