I have a Jenkins job that is checking out a repository, compiling a C project, and then is supposed to stage, commit and push the generated binaries. However, the job fails at staging/committing the binaries because it does not detect any changes and therefore has nothing to commit.
In the PowerShell script that does the compilation, after the binary image is created I copy it to another directory where it is tracked in our repository.
Source binary file:
.\device_test\images\Device_ROYAL_Firmware_Development.0.img
Destination binary file (the one that is tracked):
.\device_platforms\nordic15_2\device_device\device_out\ROYAL_FW_40.04.10.0.bin
Despite the destination binary file showing an updated LastWriteTime before and after being overwritten, git status
does not show that file as modified and git add -f binaryfile
does nothing.
Build #1
Copying version header...
Current FW version: #define DEVICE_FW_VERSION "40.04.10.0"
Compiling .\device_platforms\nordic15_2\device_device\pca10100e\s112\arm5_no_packs\device.uvprojx...
Keil build successful! image=.\device_platforms\nordic15_2\device_device\device_out\ROYAL_FW_40.04.10.0.bin
Image pre-copy modified: 10/17/2022 12:35:44
Copying image file .\device_platforms\nordic15_2\device_device\device_out\ROYAL_FW_40.04.10.0.bin to .\device_test\images\Device_ROYAL_Firmware_Development.0.img...
Image post-copy modified: 10/17/2022 12:41:45
Adding image file .\device_test\images\Device_ROYAL_Firmware_Development.0.img to git...
Running git status
before overwriting the file, of course, does not show the file as having been modified.
HEAD detached from 5a36217fa
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Device_lib/projects/keil/Device_lib.lib
modified: Device_platforms/nordic15_2/Device_device/Device_fw_version/Device_fw_version_ROYAL.h
modified: Device_platforms/nordic15_2/Device_device/Device_hw_config/Device_hw_config.h
deleted: Device_platforms/nordic15_2/Device_device/Device_out/.gitignore
Untracked files:
(use "git add <file>..." to include in what will be committed)
Device_major_version_ROBIN.txt
Device_major_version_ROYAL.txt
cppcheck-result-Devicelib.xml
cppcheck-result-Deviceshim.xml
doxygen/
git_output.txt
Device_fw_version_ROBIN.0.h
Device_fw_version_ROBIN.1.h
Device_fw_version_ROBIN.2.h
Device_fw_version_ROBIN.3.h
Device_fw_version_ROYAL.0.h
Device_fw_version_ROYAL.1.h
Device_fw_version_ROYAL.2.h
Device_fw_version_ROYAL.3.h
Device_lib/projects/keil/keil_log
Device_platforms/nordic15_2/Device_device/pca10100e/s112/arm5_no_packs/RTE/_nrf52820_xxaa/
Device_platforms/nordic15_2/Device_device/pca10100e/s112/arm5_no_packs/keil_log
Device_test/images/.gitignore
no changes added to commit (use "git add" and/or "git commit -a")
But there are still no changes to the destination file needing to be staged after overwriting the file.
HEAD detached from 5a36217fa
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: Device_lib/projects/keil/Device_lib.lib
modified: Device_platforms/nordic15_2/Device_device/Device_fw_version/Device_fw_version_ROYAL.h
modified: Device_platforms/nordic15_2/Device_device/Device_hw_config/Device_hw_config.h
deleted: Device_platforms/nordic15_2/Device_device/Device_out/.gitignore
Untracked files:
(use "git add <file>..." to include in what will be committed)
Device_major_version_ROBIN.txt
Device_major_version_ROYAL.txt
cppcheck-result-Devicelib.xml
cppcheck-result-Deviceshim.xml
doxygen/
git_output.txt
Device_fw_version_ROBIN.0.h
Device_fw_version_ROBIN.1.h
Device_fw_version_ROBIN.2.h
Device_fw_version_ROBIN.3.h
Device_fw_version_ROYAL.0.h
Device_fw_version_ROYAL.1.h
Device_fw_version_ROYAL.2.h
Device_fw_version_ROYAL.3.h
Device_lib/projects/keil/keil_log
Device_platforms/nordic15_2/Device_device/pca10100e/s112/arm5_no_packs/RTE/_nrf52820_xxaa/
Device_platforms/nordic15_2/Device_device/pca10100e/s112/arm5_no_packs/keil_log
Device_test/images/.gitignore
no changes added to commit (use "git add" and/or "git commit -a")
For comparison, listing the files in .\device_test\images before overwriting shows the file as being modified at 10/17/2022 12:35 PM
Directory: E:\jenkins\home\DeviceLib2_dev_src\Device_test\images
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 10/14/2022 6:51 PM 14 .gitattributes
-a---- 10/15/2022 10:32 AM 6 .gitignore
-a---- 10/14/2022 6:51 PM 86 commit_hash
... (list shortened)
-a---- 10/15/2022 10:27 AM 41316 Device_ROBIN_Firmware_Development.0.img
-a---- 10/15/2022 10:27 AM 41316 Device_ROBIN_Firmware_Development.1.img
-a---- 10/15/2022 10:23 AM 41316 Device_ROBIN_Firmware_Development.2.img
-a---- 10/15/2022 10:24 AM 41316 Device_ROBIN_Firmware_Development.3.img
-a---- 10/17/2022 12:35 PM 41316 Device_ROYAL_Firmware_Development.0.img
-a---- 10/17/2022 12:36 PM 41316 Device_ROYAL_Firmware_Development.1.img
-a---- 10/17/2022 12:37 PM 41316 Device_ROYAL_Firmware_Development.2.img
-a---- 10/17/2022 12:38 PM 41316 Device_ROYAL_Firmware_Development.3.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.0.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.1.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.2.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.3.img
And shows an updated LastWriteTime of 10/17/2022 12:41 PM after overwriting.
Directory: E:\jenkins\home\DeviceLib2_dev_src\Device_test\images
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 10/14/2022 6:51 PM 14 .gitattributes
-a---- 10/15/2022 10:32 AM 6 .gitignore
-a---- 10/14/2022 6:51 PM 86 commit_hash
... (list shortened)
-a---- 10/15/2022 10:27 AM 41316 Device_ROBIN_Firmware_Development.0.img
-a---- 10/15/2022 10:27 AM 41316 Device_ROBIN_Firmware_Development.1.img
-a---- 10/15/2022 10:23 AM 41316 Device_ROBIN_Firmware_Development.2.img
-a---- 10/15/2022 10:24 AM 41316 Device_ROBIN_Firmware_Development.3.img
-a---- 10/17/2022 12:41 PM 41316 Device_ROYAL_Firmware_Development.0.img
-a---- 10/17/2022 12:36 PM 41316 Device_ROYAL_Firmware_Development.1.img
-a---- 10/17/2022 12:37 PM 41316 Device_ROYAL_Firmware_Development.2.img
-a---- 10/17/2022 12:38 PM 41316 Device_ROYAL_Firmware_Development.3.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.0.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.1.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.2.img
-a---- 10/14/2022 6:51 PM 40228 Device_Whippet_Firmware_Development.3.img
I can go into the local repository with a command-line, manually copy the source to the destination and git status
will correctly show the file as modified. It therefore seems to be isolated when these steps are run by Jenkins. As a starting point, I wonder if the steps taken by the Git SCM plugin in Jenkins have any influence.
git.exe rev-parse --resolve-git-dir localrepo\.git
git.exe config remote.origin.url git@github.com:remoterepo.git
git.exe --version
git --version
git.exe fetch --tags --progress -- git@github.com:remoterepo.git +refs/heads/*:refs/remotes/origin/*
git.exe rev-parse "refs/remotes/origin/branch_name^{commit}"
git.exe config core.sparsecheckout
git.exe checkout -f 63cd0f5b1fd084291ab9f97bd3f03a4d2079101c
git.exe rev-list --no-walk b42d583949d13f5ea9de729b61ab7be81c699bb6
Update:
To @LeGEC's recommendation, git update-index --refresh
shows the same unstaged changes- the binary file not being shown in either case.
Device_lib/projects/keil/Device_lib.lib: needs update
Device_platforms/nordic15_2/Device_device/Device_fw_version/Device_fw_version_ROYAL.h: needs update
Device_platforms/nordic15_2/Device_device/Device_hw_config/Device_hw_config.h: needs update
Device_platforms/nordic15_2/Device_device/Device_out/.gitignore: needs update