Can you remotely trigger to run scripts in your repo with Jenkins (the script is not related to builds)

Viewed 122

There is a python script in my repo that I would like to run whenever I call an API.This Python script merely transfer data from one database to another. The Jenkins server for the project currently is used for builds/pipelines/running tests, I was wondering if I could use this Jenkins service to run this script when i call an API since I found that Jenkins allows you to remotely trigger scripts via REST.

I was wondering it I could use Jenkin's feature of trigger remotely to run this python script in my repo when I need to. The python script is built using a python image in the dockerfile, so docker helps to setup the dependencies/python needed to run the script. the command to run by Jenkins is something like docker build and docker run

1 Answers

Yes you can.

Just setup a pipeline that

  1. Runs in docker (with your image). Have a look at this
  2. Does a git clone of you repository
  3. Runs you python script with something like: sh "python <your script>"
Related