Reputation: 1166
Trying to setup Jenkins running inside docker container and also being able to run containers there.
When I run first build all works great but when I run second one I am hitting following problem.
Does anyone know what could be the issue?
Here is the log from pipeline
Started by user Vit @ Jarmill
Replayed #4
Connecting to https://api.github.com using admin/****** (GitHub Access Token)
Obtained Jenkinsfile from 382099092e83938b97a09ec5c8d627dd7456411d
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/iamwtk_site_master- E6LR65PLWYZWNGUMZKPLCLOJ337SJ4G4F2WDI7TROT63NGV36NEQ
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Declarative: Checkout SCM)
[Pipeline] checkout
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/iamwtk/iamwtk_site.git # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/iamwtk/iamwtk_site.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:85)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:75)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:47)
at hudson.security.ACL.impersonate(ACL.java:290)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:44)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: hudson.plugins.git.GitException: Command "git clean -fdx" returned status code 1:
stdout: Removing front_end_server@tmp/
stderr: warning: failed to remove front_end_server/dist/server.js
warning: failed to remove front_end_server/dist/client/views/index.ejs
// and many more ....
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2002)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1970)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1966)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1597)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1609)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.clean(CliGitAPIImpl.java:787)
at hudson.plugins.git.GitAPI.clean(GitAPI.java:311)
at hudson.plugins.git.extensions.impl.CleanBeforeCheckout.decorateFetchCommand(CleanBeforeCheckout.java:30)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:884)
... 13 more
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
GitHub has been notified of this commit’s build result
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
I started container with following settings:
docker volume create --name data_jenkins
docker run --name jenkins -d -v data_jenkins:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
I already installed docker inside the container with daemon linking via volume to host machine daemon. I set jenkins user to docker group to be able to run docker commands without sudo.
I am quite sure this must be problem of permissions I just really cannot find where. Already spent all day on this, hope somebody could point me right direction.
Upvotes: 5
Views: 12500
Reputation: 1
To solve this issue you need to clean your workspace
1.copy workspace path(you can copy path of your workspace from console output of your job) ex:- /opt/jenkins/workspace/job_name
2.Open shell or ssh to Jenkins Instance(In case of VM or EC2 instance)
Upvotes: 0
Reputation: 435
I just did this:
stage('delete files from workspace') {
steps {
sh 'ls -l'
sh 'sudo rm -rf ./*'
}
}
as one of the steps before the scm checkout and it worked like a charm.
Upvotes: 0
Reputation: 1166
Problem was with permissions in workspace directory where the build was stored.
Changed permissions to allow jenkins user to rwx and problem solved.
Upvotes: 0