Home > Software engineering >  How can I get changed files list in my jenkins pipeline
How can I get changed files list in my jenkins pipeline

Time:01-03

I'm trying to get all files that changed in my branch. i tried many commands but found out that probably there is issue in my jenkins pipeline, no command return the correct list.

I wanna get the list from point i checked out the master, the master may got forwarded by others.

Locally there are some commands that return the correct changed files list:

git diff --name-only origin/master...   
git diff --name-only $(git merge-base HEAD origin/master)..

The list:

e2e-v2/src/__specs__/alerts/alert-definitions.test.ts

tools/jenkins/e2e.groovy

tools/scripts/package.json

from some reason, in Jenkins the return list is:

tools/docker-collector-metrics/docker.yml

tools/docker-collector-metrics/system.yml

tools/jenkins/.env

I cannot understand why it different.
Maybe there are some context issue?

CodePudding user response:

You can execute a shell step in your Jenkins job

git log -10 --graph --decorate --oneline
git remote -v
git branch -avv

That would display the last 10 commits from HEAD, as well as the remote and branches checked out by your Jenkins job.

Do the same locally, and you can make sure you are in the same context/history or not.

CodePudding user response:

Could you so your pipeline code?

I'm call a python file to execute this request https://bitbucket.example.com/rest/api/1.0/projects/**project-name**/repos/**repo-name**/pull-requests/number-of-pullrequest/changes?limit=1000 (using bitbucket repo)

One more suggestion: you can try add clone your repository steps in pipeline, then execute the git command in the directory you clone repo.

  • Related