package.json not found in Jenkins
My Dockerfile looks something like this.
FROM mhart/alpine-node:8.11.3
RUN mkdir -p /app
COPY ./ /app
WORKDIR /app/build
RUN yarn global add serve
CMD ["serve", "-l", "3000"]
EXPOSE 3000
And then JenkinsFile looks something like this.
node {
try {
stage('Checkout source code') {
checkout scm
}
stage('Install packages') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn install")
//sh("sudo chown -R jenkins: ./node_modules")
}
stage('Set the enviroment variables') {
sh("echo set-env-variables")
}
stage('Build static assets') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn build")
}
}}
When i do run it on Jenkins,the console output says error Couldn't find a package.json file in "/app"
and also it gives an error sudo not found
even though i have added jenkins ALL=(ALL) NOPASSWD: ALL
to /etc/sudoers file.
I run the commands listed in my Jenkinsfile on my terminal and they all work fine but when i run them on Jenkins , they dont work.
docker jenkins jenkins-pipeline dockerfile
add a comment |
My Dockerfile looks something like this.
FROM mhart/alpine-node:8.11.3
RUN mkdir -p /app
COPY ./ /app
WORKDIR /app/build
RUN yarn global add serve
CMD ["serve", "-l", "3000"]
EXPOSE 3000
And then JenkinsFile looks something like this.
node {
try {
stage('Checkout source code') {
checkout scm
}
stage('Install packages') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn install")
//sh("sudo chown -R jenkins: ./node_modules")
}
stage('Set the enviroment variables') {
sh("echo set-env-variables")
}
stage('Build static assets') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn build")
}
}}
When i do run it on Jenkins,the console output says error Couldn't find a package.json file in "/app"
and also it gives an error sudo not found
even though i have added jenkins ALL=(ALL) NOPASSWD: ALL
to /etc/sudoers file.
I run the commands listed in my Jenkinsfile on my terminal and they all work fine but when i run them on Jenkins , they dont work.
docker jenkins jenkins-pipeline dockerfile
If you navigate to the./app
folder is there apackage.json
file there?...
– War10ck
Nov 13 '18 at 16:43
I am copying the entire current working dir to /app in docker container usingCOPY ./ /app
in Dockerfile.So i suppose package.json should be present in the container.
– Ricky Sterling
Nov 13 '18 at 16:46
If you are copying your entire files already under /app why mount pwd again?
– Ravindranath Barathy
Nov 13 '18 at 16:59
I guess that i am not building the image using Dockerfile so its just making a temp container which gets destroyed after the execution.docker run --rm -v
pwd:/app -w /app node yarn build
, its just creating a temp container.
– Ricky Sterling
Nov 13 '18 at 17:06
add a comment |
My Dockerfile looks something like this.
FROM mhart/alpine-node:8.11.3
RUN mkdir -p /app
COPY ./ /app
WORKDIR /app/build
RUN yarn global add serve
CMD ["serve", "-l", "3000"]
EXPOSE 3000
And then JenkinsFile looks something like this.
node {
try {
stage('Checkout source code') {
checkout scm
}
stage('Install packages') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn install")
//sh("sudo chown -R jenkins: ./node_modules")
}
stage('Set the enviroment variables') {
sh("echo set-env-variables")
}
stage('Build static assets') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn build")
}
}}
When i do run it on Jenkins,the console output says error Couldn't find a package.json file in "/app"
and also it gives an error sudo not found
even though i have added jenkins ALL=(ALL) NOPASSWD: ALL
to /etc/sudoers file.
I run the commands listed in my Jenkinsfile on my terminal and they all work fine but when i run them on Jenkins , they dont work.
docker jenkins jenkins-pipeline dockerfile
My Dockerfile looks something like this.
FROM mhart/alpine-node:8.11.3
RUN mkdir -p /app
COPY ./ /app
WORKDIR /app/build
RUN yarn global add serve
CMD ["serve", "-l", "3000"]
EXPOSE 3000
And then JenkinsFile looks something like this.
node {
try {
stage('Checkout source code') {
checkout scm
}
stage('Install packages') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn install")
//sh("sudo chown -R jenkins: ./node_modules")
}
stage('Set the enviroment variables') {
sh("echo set-env-variables")
}
stage('Build static assets') {
sh("docker run --rm -v `pwd`:/app -w /app node yarn build")
}
}}
When i do run it on Jenkins,the console output says error Couldn't find a package.json file in "/app"
and also it gives an error sudo not found
even though i have added jenkins ALL=(ALL) NOPASSWD: ALL
to /etc/sudoers file.
I run the commands listed in my Jenkinsfile on my terminal and they all work fine but when i run them on Jenkins , they dont work.
docker jenkins jenkins-pipeline dockerfile
docker jenkins jenkins-pipeline dockerfile
edited Nov 13 '18 at 17:12
Ricky Sterling
asked Nov 13 '18 at 16:41
Ricky SterlingRicky Sterling
728
728
If you navigate to the./app
folder is there apackage.json
file there?...
– War10ck
Nov 13 '18 at 16:43
I am copying the entire current working dir to /app in docker container usingCOPY ./ /app
in Dockerfile.So i suppose package.json should be present in the container.
– Ricky Sterling
Nov 13 '18 at 16:46
If you are copying your entire files already under /app why mount pwd again?
– Ravindranath Barathy
Nov 13 '18 at 16:59
I guess that i am not building the image using Dockerfile so its just making a temp container which gets destroyed after the execution.docker run --rm -v
pwd:/app -w /app node yarn build
, its just creating a temp container.
– Ricky Sterling
Nov 13 '18 at 17:06
add a comment |
If you navigate to the./app
folder is there apackage.json
file there?...
– War10ck
Nov 13 '18 at 16:43
I am copying the entire current working dir to /app in docker container usingCOPY ./ /app
in Dockerfile.So i suppose package.json should be present in the container.
– Ricky Sterling
Nov 13 '18 at 16:46
If you are copying your entire files already under /app why mount pwd again?
– Ravindranath Barathy
Nov 13 '18 at 16:59
I guess that i am not building the image using Dockerfile so its just making a temp container which gets destroyed after the execution.docker run --rm -v
pwd:/app -w /app node yarn build
, its just creating a temp container.
– Ricky Sterling
Nov 13 '18 at 17:06
If you navigate to the
./app
folder is there a package.json
file there?...– War10ck
Nov 13 '18 at 16:43
If you navigate to the
./app
folder is there a package.json
file there?...– War10ck
Nov 13 '18 at 16:43
I am copying the entire current working dir to /app in docker container using
COPY ./ /app
in Dockerfile.So i suppose package.json should be present in the container.– Ricky Sterling
Nov 13 '18 at 16:46
I am copying the entire current working dir to /app in docker container using
COPY ./ /app
in Dockerfile.So i suppose package.json should be present in the container.– Ricky Sterling
Nov 13 '18 at 16:46
If you are copying your entire files already under /app why mount pwd again?
– Ravindranath Barathy
Nov 13 '18 at 16:59
If you are copying your entire files already under /app why mount pwd again?
– Ravindranath Barathy
Nov 13 '18 at 16:59
I guess that i am not building the image using Dockerfile so its just making a temp container which gets destroyed after the execution.
docker run --rm -v
pwd:/app -w /app node yarn build
, its just creating a temp container.– Ricky Sterling
Nov 13 '18 at 17:06
I guess that i am not building the image using Dockerfile so its just making a temp container which gets destroyed after the execution.
docker run --rm -v
pwd:/app -w /app node yarn build
, its just creating a temp container.– Ricky Sterling
Nov 13 '18 at 17:06
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285682%2fpackage-json-not-found-in-jenkins%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53285682%2fpackage-json-not-found-in-jenkins%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
If you navigate to the
./app
folder is there apackage.json
file there?...– War10ck
Nov 13 '18 at 16:43
I am copying the entire current working dir to /app in docker container using
COPY ./ /app
in Dockerfile.So i suppose package.json should be present in the container.– Ricky Sterling
Nov 13 '18 at 16:46
If you are copying your entire files already under /app why mount pwd again?
– Ravindranath Barathy
Nov 13 '18 at 16:59
I guess that i am not building the image using Dockerfile so its just making a temp container which gets destroyed after the execution.
docker run --rm -v
pwd:/app -w /app node yarn build
, its just creating a temp container.– Ricky Sterling
Nov 13 '18 at 17:06