For simplicity, you can create a Jenkinsfile at the root of the git repository, similar to the below example 'Jenkinsfile' based on the groovy syntax of the declarative pipeline.
pipeline {
agent any
stages {
stage('Build the Project') {
steps {
git 'https://github.com/jaikrgupta/CarthageAPI-1.0.git'
echo pwd()
sh 'ls -alrt'
sh 'pip install -r requirements.txt'
sh 'python app.py &'
echo "Build stage gets finished here"
}
}
stage('Test') {
steps {
sh 'chmod 777 ./scripts/test-script.sh'
sh './scripts/test-script.sh'
sh 'cat ./test-reports/test_script.log'
echo "Test stage gets finished here"
}
}
}
https://github.com/jaikrgupta/CarthageAPI-1.0.git
You can now set up a new item in Jenkins as a Pipeline job. Select the
Definition
asPipeline script from SCM
andGit
for theSCM
option. Paste the project's git repo link in the Repository URL andJenkinsfile
in the script name box. Then click on thelightweight checkout
option and save the project. So whenever you pushed a commit to the git repo, you can always test the changes running theBuild Now
every time in Jenkins.
Please follow the instructions in the below visuals for easy setup a Jenkins Pipeline's job.