0

I'm a very beginner in Jenkins and afraid that I ask you something not clear with a weird question.

I'd like to deploy my simple node app server to Ubuntu via Jenkins.

I tried to write a command in Build at a Job as below :

./script/deploy.sh

deploy.sh file is here.

#!/bin/sh
EOF
 npm install
 pm2 restart app.js --name="myApp"
 exit
EOF

When I run a build, it stucked with error as

FATAL: Could not checkout 0d563b394d506e8450833e9b36d7a7b44834df39

The Full log of Error.

 > git checkout -f 0d563b394d506e8450833e9b36d7a7b44834df39
FATAL: Could not checkout 0d563b394d506e8450833e9b36d7a7b44834df39
hudson.plugins.git.GitException: Command "git checkout -f 0d563b394d506e8450833e9b36d7a7b44834df39" returned status code 1:
stdout: 
stderr: error: unable to unlink old 'node_modules/express-session/HISTORY.md': Permission denied
error: unable to unlink old 'node_modules/express-session/LICENSE': Permission denied
error: unable to unlink old 'node_modules/express-session/README.md': Permission denied
error: unable to unlink old 'node_modules/express-session/index.js': Permission denied
error: unable to unlink old 'node_modules/express-session/package.json': Permission denied
error: unable to unlink old 'node_modules/express-session/session/cookie.js': Permission denied
error: unable to unlink old 'node_modules/express-session/session/memory.js': Permission denied
error: unable to unlink old 'node_modules/express-session/session/session.js': Permission denied
error: unable to unlink old 'node_modules/express-session/session/store.js': Permission denied
HEAD is now at 0d563b3 commit

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$900(CliGitAPIImpl.java:72)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2341)
Caused: hudson.plugins.git.GitException: Could not checkout 0d563b394d506e8450833e9b36d7a7b44834df39
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$9.execute(CliGitAPIImpl.java:2365)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1242)
    at hudson.scm.SCM.checkout(SCM.java:504)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
    at hudson.model.Run.execute(Run.java:1816)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:429)
Finished: FAILURE

My questions :

1. How to deploy a node app to ubuntu via Jenkins.

  • Is my way right? or another way is better?

2. What error is it as following the log.

3 Answers 3

2

This article very clearly explains how to deploy a nodejs app using Jenkins:

https://blog.couchbase.com/create-continuous-deployment-pipeline-nodejs-jenkins/

1

delete your job, create a new one, add a step clean workspace as the first step of your job. with pipelines it is cleanWs(). see plugin doc here: https://wiki.jenkins.io/display/JENKINS/Workspace+Cleanup+Plugin

0

You have a GIT permissions issue (you cannot write to files and or directory):

https://stackoverflow.com/questions/11774397/git-push-error-unable-to-unlink-old-permission-denied

stderr:
error: unable to unlink old 'node_modules/express-session/HISTORY.md': Permission denied
error: unable to unlink old 'node_modules/express-session/LICENSE': Permission denied
error: unable to unlink old 'node_modules/express-session/README.md': Permission denied
error: unable to unlink old 'node_modules/express-session/index.js': Permission denied
error: unable to unlink old 'node_modules/express-session/package.json': Permission denied
error: unable to unlink old 'node_modules/express-session/session/cookie.js': Permission denied
error: unable to unlink old 'node_modules/express-session/session/memory.js': Permission denied
error: unable to unlink old 'node_modules/express-session/session/session.js': Permission denied
error: unable to unlink old 'node_modules/express-session/session/store.js': Permission denied
2
  • Thought I didn't assume the permission problem because when I checked the webhook in Github, showed me verified. Commented Apr 23, 2019 at 10:45
  • The problem had been happening after a Jenkins job runs few times. Commented Apr 23, 2019 at 10:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.