Jenkins build step doesn't execute as it should.
I try to download my project from GitHub repository using Jenkins and then to build. Later I will join tomcat server and automatically host on localhost or aws.
Currently something is wrong. I have this script:
I call it using
call build-script.bat
in Jenkins step Execute Windows batch command
.
But Instead of executing all the script Jenkins finishes it prematurely:47 Replies
⌛
This post has been reserved for your question.
Hey @Tomasm21! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Why is that?
Are you doing CI things on Windows? Why?
Can you try printing the errorlevel for testing?
maybe the
npm -v
exits for some reason?Yes I am. Why not?
Maybe you could change it to
cmd /c npm -v
?I don't know how yet.
because scripting on Windows is annoying and Windows eats up resources
Maybe. But when I do it manually.. I mean if I clone my repository using CMD and then navigating to the directory and doing
npm -v
then it shows version:
9.6.4
which is different than Jenkins 9.3.1
.
And then tried to manually install node modules:
npm install
And it installed node modules.
But this part in batch script file is omitted:
so it omits these parts and continues later?
I don't really know batch tbh but to me, it looks like it's just the script aborting
It doesn;t continue if I do the whole batch file.
It executes when I launch commands one by one.
and maybe npm is just a batch file that does
exit 0
which propagates to your script for some reason
which is why I suggested replacing npm -v
with cmd /c npm -v
Jenkins shell script doesn't work even more. So I asked chatGPT to convert bash script to Windows batch.
idk why Windows does that (if you exit from a batch script in a batch script, it might exit out of both scripts) but I vaguely remember something like this
so try that and tell me what happens
ok I will try it. The overall script will be this:
Right?
Or maybe to highlight important place with more comments:
I guess
Now it is installing the dependencies. I guess
cmd /c npm -v
was the solution
but right after installing all dependencies the build stopped. and exited.
Perhaps I have to add cmd /c ...
before all npm
s.
Right.💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
The overall batch file that works well is now:
The
cmd /c
in front of every major command that works with either npm
or mvn
. Even in front of xcopy ...
.I think it's only necessary if the commands are batch files
and there are probably also other ways to do this
But I guess this means it works?
Yes it does.
Though I have another problem when the web app is hosted on Tomcat. I open it and I see that it is not found.
And I really don't know why.
When I launch the app locally - backend Spring Boot launching On Eclipse, and frontend React.js through Visual Code terminal
npm start
then the application on browser works through localhost:3000/maitinimas
.
But on Tomcat it should be http://localhost:2020/maitinimas
because tomcat is on 2020. Actually when press the app in applications list it opens at http://localhost:2020/Maitinimas-0.0.1-SNAPSHOT/
. I thought it had to be http://localhost:2020/Maitinimas
, because in React.js package.json I have "homepage": "/Maitinimas/",
. And in Spring application.properties
I have
.
The content that loads in the web app:
Do you know how to solve this? Is this in your scope of knowledge?Can you try with
http://localhost:2020/Maitinimas-0.0.1-SNAPSHOT/Maitinimas
?
If that doesn't work, can you try with server.servlet.context-path=/Maitinimas-0.0.1-SNAPSHOT
and http://localhost:2020/Maitinimas-0.0.1-SNAPSHOT
?the same
Message The requested resource [/Maitinimas-0.0.1-SNAPSHOT/Maitinimas] is not available
I can try to change this line in application proiperties and the rebuild
Doing it.Can you show your pom.xml?
yes
hold on..
this version should not exist:
<version>2.7.18</version>
Perhaps I accidentally put the mouse pointer and by a chance pressed 8 in keyboard. And saved
its 2.7.1So there isn't anything adding the frontend to the war file?
Nevcertheless, locally the app can be launched:
It should add.
What should add it? I saw nothing supposed to add it
the build from frontend is supposed tro be copied to the
\src\main\resources\public\
oh
Any specific reason you put it in
public
?Lets examine this part:
try coping it to
src/main/resources/static
everything in the static directory
because Spring will serve everything in static
1:1I was taught to copy frontend files to public. In past it worked
Are you sure? Should I change batch command at copying?
normally yes
Sure it wasn't
src/main/resources/static/public
?from
to
I mean it would also possible with
public
but static
works without extra configuration?
I guessI copied it from past working project.
I guess that other project had extra (Spring) configuration
so anyway.... What should I do? To change
server.servlet.context-path=/Maitinimas
to the server.servlet.context-path=/Maitinimas-0.0.1-SNAPSHOT
?
When I launch this app on docker, it works well. But I need JenkinsI'd first try without any
server.servlet.context-path
and use localhost:2000//Maitinimas-0.0.1-SNAPSHOT
or whatever it was
then you can try figuring out how to do it differentlyTried. Was the same. ChatGPT offered
server.servlet.context-path
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
Post Closed
This post has been closed by <@312509109863710732>.