On Mon, Feb 1, 2021 at 1:54 PM Patrick Moran wrote: > Mark, > > I tried to reproduce your steps as best I could. > - I already have git, java and jenkins installed so I did not re-install > them. > - I added the git and java paths to the jenkins configuration. > - I replaced my repo with a public repo on GitHub since it looks like I > would need credentials to access yours. > > I still get the same error. > > I did notice the following: > > - If I add a bat 'dir' command to the test stage, it shows that the > directory is the jenkins working directory, but there are no files in that > directory. > - Once the pipeline has completed, I can look at the jenkins working > directory and see all the files I expect to be there. > - If I try to run a batch file from the repo in the test stage (or any > other stage), I get an error that the file does not exist. > - If I try to run a batch file from a different directory on the machine > it successfully runs that batch file. > > It seems like the checkout has not actually cloned the repo to my jenkins > workspace while running the pipeline, but that the files are there when the > pipeline has finished. Is this correct? > > Since you didn't share your Pipeline definition file, it is difficult to state what should be expected. In the declarative Pipeline definition that I shared, the option " skipDefaultCheckout true " is enabled. When that is enabled, then the declarative pipeline does not perform a checkout implicitly when it starts. Without the skipDefaultCheckout true option, the declarative pipeline performs a checkout step on the agent before any other steps. If you are using a scripted pipeline, then there is no default checkout.
The sequence of execution is something like: 1. Jenkins controller finds the Jenkinsfile in the repository and requests a copy of the Jenkinsfile 2. Jenkins controller begins executing the Jenkinsfile 3. If the Jenkinsfile is a declarative pipeline and skipDefaultCheckout is not enabled, then an implicit checkout scm is performed on the agent 4. Other steps in the Jenkinsfile are executed Mark Waite > Thanks, > Pat > > On Friday, January 29, 2021 at 8:47:53 PM UTC-6 Patrick Moran wrote: > >> Thanks Mark! I am new to Jenkins so it may take me a while to go through >> everything you’ve done here. >> >> On Jan 29, 2021, at 7:21 PM, Mark Waite <[email protected]> wrote: >> >> >> >> I made my best guess at the steps you took and was unable to duplicate >> the problem. You'll need to provide more details of the steps you took and >> how your system is configured. Steps I took included (with no claim that >> any of these steps are especially crucial, they just happen to be the steps >> that I took): >> >> - Installed PortableGit-2.30.0.2 in C:\J\Tools\PortableGit-2.30.0.2 >> and added C:\J\Tools\PortableGit-2.30.0.2\bin to my PATH >> - Installed AdoptOpenJDK Java 8u282 in C:\J\Tools\jfk8u282-b08 and >> added C:\J\Tools\jfk8u282-b08\bin to my PATH and C:\J\Tools\jfk8u282-b08 >> as JAVA_HOME >> - Download Jenkins 2.264.4-rc to my Windows 10 computer (used that >> version because I wanted to also test that version) >> - Run jenkins with the command "java -jar jenkins.war" from a Windows >> Command Prompt >> - Create a GitHub Personal Access Token on my GitHub account with >> full permissions >> - Define a Jenkinsfile in the feature/test-PM branch of my >> https://github.com/MarkEWaite/bin.git repository >> - Create a Pipeline job that uses the personal access token to clone >> the feature/test-PM branch of my https://github.com/MarkEWaite/bin.git >> repository using the personal access token >> - Confirm that the Pipeline job checkout works as expected >> - Create a Multibranch Pipeline job with Git as the branch provider >> for the https://github.com/MarkEWaite/bin.git repository using the >> personal access token >> - Confirm that the Multibranch Pipeline job checkout with Git works >> as expected >> - Create a Multibranch Pipeline job with GitHub as the branch >> provider for the https://github.com/MarkEWaite/bin.git repository >> using the personal access token >> - Confirm that the Multibranch Pipeline job checkout with GitHub >> works as expected >> - Create a Multibranch Pipeline job with single source as the branch >> provider for the https://github.com/MarkEWaite/bin.git repository >> using the personal access token >> - Confirm that the Multibranch Pipeline job with single source works >> as expected >> >> >> The declarative Pipeline Jenkinsfile I used and permuted in various ways >> was: >> >> pipeline { >> agent { >> label 'windows' >> } >> >> options { >> skipDefaultCheckout true >> } >> >> stages { >> stage('Build') { >> steps { >> echo 'Building' >> checkout([$class: 'GitSCM', >> branches: [[name: 'feature/test-PM']], >> userRemoteConfigs: [[credentialsId: >> 'github-access-token', >> url: ' >> https://github.com/MarkEWaite/bin.git']]]) >> bat 'type ngrok.yml' >> } >> } >> >> stage('Test') { >> steps { >> echo 'Testing' >> bat 'type docker_scrub.sh' >> } >> } >> >> stage('Deploy') { >> steps { >> echo 'Deploying' >> bat 'type inbound-jenkins-agent-alpine' >> } >> } >> } >> } >> >> On Fri, Jan 29, 2021 at 2:00 PM Patrick Moran <[email protected]> >> wrote: >> >>> Thanks for the reply Mark. I updated my pipeline script branch setting >>> in the checkout step to "origin/feature/test-PM" but the output was the >>> same. >>> >>> ... >>> stage('Checkout') { >>> steps { >>> checkout([ >>> $class: 'GitSCM', >>> branches: [[name: 'origin/feature/test-PM']], >>> userRemoteConfigs: [[credentialsId: >>> 'b5255326-bc83-40e7-847d-d4bd6a597f40', url: ' >>> https://git.virtualincision.net/scm/a4sw/surgeon-console-software.git']] >>> ]) >>> } >>> } >>> ... >>> >>> On Friday, January 29, 2021 at 2:33:24 PM UTC-6 Mark Waite wrote: >>> >>>> May want to try "origin/feature/test-PM" instead >>>> >>>> On Fri, Jan 29, 2021 at 1:25 PM Patrick Moran <[email protected]> >>>> wrote: >>>> >>>>> Hello, >>>>> >>>>> >>>>> >>>>> I have installed Jenkins on my Windows 10 machine, created a pipeline >>>>> and run it. When it runs I get a message "ERROR: Unable to retrieve >>>>> commit message" when I try to checkout the last commit. The commit >>>>> number is correct and I can run the steps listed in the console output by >>>>> hand without the error. Does anyone know why I am getting this error? >>>>> >>>>> I am using Jenkins 2.263.3 and Git plugin 4.5.2. >>>>> >>>>> Note that I get the same error whether I use a pipeline or freestyle >>>>> project. I am not checking out the master branch, does that matter? >>>>> >>>>> The pipeline used (credentials and repo url XXXX'ed out): >>>>> >>>>> #!/usr/bin/env groovy >>>>> >>>>> >>>>> >>>>> pipeline { >>>>> >>>>> agent any >>>>> >>>>> stages { >>>>> >>>>> stage('Checkout') { >>>>> >>>>> steps { >>>>> >>>>> checkout([ >>>>> >>>>> $class: 'GitSCM', >>>>> >>>>> branches: [[name: 'feature/test-PM']], >>>>> >>>>> userRemoteConfigs: [[credentialsId: 'XXXXXX', >>>>> url: 'XXXXXX']] >>>>> >>>>> ]) >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> stage('Build') { >>>>> >>>>> steps { >>>>> >>>>> echo "Build is $BUILD_NUMBER : Node name is >>>>> $NODE_NAME" >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> stage('Test'){ >>>>> >>>>> steps { >>>>> >>>>> echo 'Testing...' >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> stage('Deploy') { >>>>> >>>>> steps { >>>>> >>>>> echo 'Deploying...' >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> The pipeline output (credentials and repo url XXXX'ed out): >>>>> >>>>> >>>>> >>>>> Running in Durability level: MAX_SURVIVABILITY >>>>> >>>>> [Pipeline] Start of Pipeline >>>>> >>>>> [Pipeline] node >>>>> >>>>> Running on Jenkins in >>>>> C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\TestBuild1 >>>>> >>>>> [Pipeline] { >>>>> >>>>> [Pipeline] stage >>>>> >>>>> [Pipeline] { (Checkout) >>>>> >>>>> [Pipeline] checkout >>>>> >>>>> The recommended git tool is: NONE >>>>> >>>>> using credential XXXXXX >>>>> >>>>> Cloning the remote Git repository >>>>> >>>>> Cloning repository XXXXXX >>>>> >>>>> > git.exe init >>>>> C:\Windows\system32\config\systemprofile\AppData\Local\Jenkins\.jenkins\workspace\TestBuild1 >>>>> # timeout=10 >>>>> >>>>> Fetching upstream changes from XXXXXX >>>>> >>>>> > git.exe --version # timeout=10 >>>>> >>>>> > git --version # 'git version 2.30.0.windows.2' >>>>> >>>>> using GIT_ASKPASS to set credentials >>>>> >>>>> > git.exe fetch --tags --force --progress -- XXXXXX >>>>> +refs/heads/*:refs/remotes/origin/* # timeout=10 >>>>> >>>>> > git.exe config remote.origin.url XXXXXX # timeout=10 >>>>> >>>>> > git.exe config --add remote.origin.fetch >>>>> +refs/heads/*:refs/remotes/origin/* # timeout=10 >>>>> >>>>> Avoid second fetch >>>>> >>>>> > git.exe rev-parse "refs/remotes/origin/feature/test-PM^{commit}" # >>>>> timeout=10 >>>>> >>>>> > git.exe rev-parse "feature/test-PM^{commit}" # timeout=10 >>>>> >>>>> Checking out Revision aeb4a265be3a3a7b1b5fc4dd655c9f0dc6f284fa >>>>> (refs/remotes/origin/feature/test-PM) >>>>> >>>>> > git.exe config core.sparsecheckout # timeout=10 >>>>> >>>>> > git.exe checkout -f aeb4a265be3a3a7b1b5fc4dd655c9f0dc6f284fa # >>>>> timeout=10 >>>>> >>>>> ERROR: Unable to retrieve commit message >>>>> >>>>> org.eclipse.jgit.errors.MissingObjectException: Missing unknown >>>>> aeb4a265be3a3a7b1b5fc4dd655c9f0dc6f284fa >>>>> >>>>> at >>>>> org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:135) >>>>> >>>>> at org.eclipse.jgit.lib.ObjectReader.open(ObjectReader.java:203) >>>>> >>>>> at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:917) >>>>> >>>>> at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:827) >>>>> >>>>> at >>>>> hudson.plugins.git.util.RevCommitRepositoryCallback.invoke(RevCommitRepositoryCallback.java:25) >>>>> >>>>> at >>>>> hudson.plugins.git.util.RevCommitRepositoryCallback.invoke(RevCommitRepositoryCallback.java:13) >>>>> >>>>> at >>>>> org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.withRepository(AbstractGitAPIImpl.java:29) >>>>> >>>>> at >>>>> org.jenkinsci.plugins.gitclient.CliGitAPIImpl.withRepository(CliGitAPIImpl.java:84) >>>>> >>>>> at hudson.plugins.git.GitSCM.printCommitMessageToLog(GitSCM.java:1394) >>>>> >>>>> at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1360) >>>>> >>>>> at >>>>> org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:125) >>>>> >>>>> at >>>>> org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93) >>>>> >>>>> at >>>>> org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80) >>>>> >>>>> at >>>>> org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) >>>>> >>>>> at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) >>>>> >>>>> at java.util.concurrent.FutureTask.run(Unknown Source) >>>>> >>>>> at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) >>>>> >>>>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) >>>>> >>>>> at java.lang.Thread.run(Unknown Source) >>>>> >>>>> > git.exe rev-list --no-walk aeb4a265be3a3a7b1b5fc4dd655c9f0dc6f284fa # >>>>> timeout=10 >>>>> >>>>> [Pipeline] } >>>>> >>>>> [Pipeline] // stage >>>>> >>>>> [Pipeline] stage >>>>> >>>>> [Pipeline] { (Build) >>>>> >>>>> [Pipeline] echo >>>>> >>>>> Build is 37 : Node name is master >>>>> >>>>> [Pipeline] } >>>>> >>>>> [Pipeline] // stage >>>>> >>>>> [Pipeline] stage >>>>> >>>>> [Pipeline] { (Test) >>>>> >>>>> [Pipeline] echo >>>>> >>>>> Testing... >>>>> >>>>> [Pipeline] } >>>>> >>>>> [Pipeline] // stage >>>>> >>>>> [Pipeline] stage >>>>> >>>>> [Pipeline] { (Deploy) >>>>> >>>>> [Pipeline] echo >>>>> >>>>> Deploying... >>>>> >>>>> [Pipeline] } >>>>> >>>>> [Pipeline] // stage >>>>> >>>>> [Pipeline] } >>>>> >>>>> [Pipeline] // node >>>>> >>>>> [Pipeline] End of Pipeline >>>>> >>>>> Finished: SUCCESS >>>>> >>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Jenkins Users" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/jenkinsci-users/CAGu5ryKes3fD-mVZBOPsDBi50LgtcO0F%3D9UsUd_tHc%3Dae%3DPatg%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/jenkinsci-users/CAGu5ryKes3fD-mVZBOPsDBi50LgtcO0F%3D9UsUd_tHc%3Dae%3DPatg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Jenkins Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/jenkinsci-users/fd3fa532-ecdd-4548-ad29-050d0d8b236fn%40googlegroups.com >>> <https://groups.google.com/d/msgid/jenkinsci-users/fd3fa532-ecdd-4548-ad29-050d0d8b236fn%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Jenkins Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtGs1AYG6JSAze0BguGdKZd8--rk3_WeXwCymo2U1MpvZw%40mail.gmail.com >> <https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtGs1AYG6JSAze0BguGdKZd8--rk3_WeXwCymo2U1MpvZw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> -- > You received this message because you are subscribed to the Google Groups > "Jenkins Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/44fc64b8-c445-40e6-b54a-d2f4c67681fan%40googlegroups.com > <https://groups.google.com/d/msgid/jenkinsci-users/44fc64b8-c445-40e6-b54a-d2f4c67681fan%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtEHJKENbBbFFvFQ2OKGspEgCM8W-vU8yjc8xOjG2Pq7kQ%40mail.gmail.com.
