Saturday, October 23, 2021

[SOLVED] Jenkins CI/CD runs a script after doing git pull on server

Issue

I want to create a CI/CD pipeline using Jenkins where whenever someone commits on master branch, two things happen on a specific "server" (EC2).

  1. First, git pull to sync with latest change
  2. Run a specific shell script present on server

Can you kindly point me in the right direction? I understand that git sync can be done with Jenkins plugin for git, but how can I run the second script "Using Jenkins flow"?


Solution

One way to do it is to add the EC2 machine where you are running the script via SSH. To this install the SSH Plugin

Then follow the steps as given here

After this you can execute the scripts by creating a new pipeline. Either a free style or multibranch pipeline. Refer the article here



Answered By - pratikvasa