So I am new to Jenkins/Git. My question may be basic but please take time to answer.
So I am trying a simple thing. I have a simple Python Script that I have pushed on git. This is it:
def about_me(your_name):
print("The wise {} loves Python.".format(your_name))
def HW():
print("Hello World!")
def Both():
HW()
about_me("Ab")
Both()
F = open(r"C:\Users\AMRABET\Documents\VSC\HW\a.txt", "a")
F.write("ok\n")
No big deal. Just a console/file print. I pushed it on master branch on my git.
Next, I tried to execute it via Jenkins. After reading multiple topics on internet, I understood that actually Jenkins does not run the code. It only build it.
So I did build it. I configured a connection between Jenkins and Git and I succeeeded. This is the output of the build:
Running as SYSTEM
Building in workspace C:\Program Files (x86)\Jenkins\workspace\GitJob
using credential 1f413199-4637-40b4-96b9-a06e1d5aab4c
> C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/MbtAbd/HelloWorld # timeout=10
Fetching upstream changes from https://github.com/MbtAbd/HelloWorld
> C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> C:\Program Files\Git\bin\git.exe fetch --tags --force --progress https://github.com/MbtAbd/HelloWorld +refs/heads/*:refs/remotes/origin/*
> C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
> C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision 34500678072eb8536821606367d6ecf329d344d9 (refs/remotes/origin/master)
> C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
> C:\Program Files\Git\bin\git.exe checkout -f 34500678072eb8536821606367d6ecf329d344d9
Commit message: "Added the file writing stuff"
> C:\Program Files\Git\bin\git.exe rev-list --no-walk 34500678072eb8536821606367d6ecf329d344d9 # timeout=10
Finished: SUCCESS
Can anyone please tell me how to run the result of the build via Jenkins? All other threads on StackOverflow suggest to execute a shell action ( sh 'python script.py' ) but in my case I don't really have the PY file.
Any help is appreciated. Thank you community!
.pyfile? It should be check out from the git repository.sh 'python script.py'executes the script on the build machine, ie. the one that just checked out your git commit. It should indeed have the script file available to it.