1

I am trying to build a Jenkins pipeline (with a Windows agent, if this could be relevant) for a project in C/C++. My jenkinsfile contains the following lines:

stage('Clone') {
  steps {
  [...]
  checkout changelog: false, poll: false,
     scm: [$class: 'GitSCM', branches: [[name: "$gitlabBranch"]],
     doGenerateSubmoduleConfigurations: false,
     extensions: [],
     submoduleCfg: [],
     userRemoteConfigs: [[credentialsId: 'gitlab-credentials', url: "$gitlabSourceRepoHttpUrl"]]]

 [...]

And the logfile is:

[Pipeline] checkout (hide)
using credential gitlab-credentials
Fetching changes from the remote Git repository
skipping resolution of commit remotes/origin/master, since it originates from another repository
Checking out Revision ccc3e1e628ffa2a4e98d847ea952f048724ffaf5 (refs/remotes/origin/master)
 > git rev-parse --is-inside-work-tree # timeout=10
 > git config remote.origin.url [URL REDACTED] # timeout=10
Fetching upstream changes from [URL REDACTED]
 > git --version # timeout=10
using GIT_ASKPASS to set credentials gitlab-credentials (https-pipeline)
Setting http proxy: [REDACTED]
 > git fetch --tags --progress -- [URL REDACTED] +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
 > git rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
 > git config core.sparsecheckout # timeout=10
 > git checkout -f ccc3e1e628ffa2a4e98d847ea952f048724ffaf5 # timeout=10
Commit message: "Update Jenkinsfile"
 > git rev-list --no-walk 628bc28a2c03a0f6f10ca1a75420c06efef16177 # timeout=10

The problem is, all data is fetched with timestamp set to the time of fetch, and therefore all files are compiled. What should I change?


I just checked, and I am sure that it is the checkout which retrieves everything: before that line, there are the old files, after that everything is updated.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mau
  • 134
  • 1
  • 10
  • Candidates for the canonical question: *[What's the equivalent of Subversion's "use-commit-times" for Git?](https://stackoverflow.com/questions/1964470/)* (2009) and *[Checking out old files WITH original create/modified timestamps](https://stackoverflow.com/questions/2179722)* (2010). Mercurial has [the Timestamp extension](https://stackoverflow.com/a/7809151) (though that does not help much). – Peter Mortensen Sep 17 '21 at 10:11

0 Answers0