how do i run script after successful build in jenkins - jenkins-plugins

I am running automated builds in jenkins after successful build the jars are copying in to my scp repository.
I configured in post build action publish artifacts in to scp repository. Everything is going fine.
But I want to stop my dev server before copying artifacts in to my dev server from jenkins.
Is it possible to stop my dev server from jenkins ?

I'm not sure if you are still looking for an answer but you can install plugin to run a script post build.
You can install the plugin by browsing to Manage Jenkin -> Manage Plugin on Jenkins. Then select Available tab. Search for the Post Build Task plugin and install

Related

Best practice for installing node_modules for a reactjs app on Azure Linux Web App

I have a react(specifically NextJS) web app running on a Linux Azure Web App Server. I have it deployed and working correctly via GitHub Actions. However, I'm having issues finding the most efficient way to deploy the node_modules.
Here's what I've tried.
I've ran the install and build within GitHub Actions and deployed the package as a zip artifact. However, the file was huge due to the node_modules and takes 10+ minutes to deploy.
I've created a postDeploy script to run after deployment that runs an npm install. Not sure if this is the best way to go about it so I reverted this.
For the startup command, I have azure running npm run start:prod. I thought about changing this to npm install && npm run start:prod . I'm not sure if this is a good idea either
What I've settled on so far is I just manually get on the server and run npm install after a deployment. This won't work for CI/CD though.
I've read that azure kudu supposedly detects package.json within the wwwroot folder and will automagically install dependencies but I haven't seen this work, nor could I find any documentation on it. So far, my best idea seems to be to change my startup command to run an install before starting the app but I'm not sure.
Any advice?
There shouldn't be a big difference between GitHub Action and Azure DevOps in that terms. But what should you do actually on your pipeline is run npm run build command and publish only produced output.
Please take a look here how it looks on Azure DevOps.

How to build and run a reactjs application in Jenkins using batch script

I have installed Jenkins on my local dev machine and I am trying to configure how to build the reactjs application by running 'npm run build' inside a Windows batch command.
When I run the build, it shows that it has changed the path, ran the npm install, even though with some error, but it does not show at all that npm run build has bee executed.
How can I execute that?
I am running Jenkins on Windows Server 2012 and this is the version of jenkins
Jenkins war org.jenkins-ci.main:jenkins-war:2.263.1 The MIT license
Jenkins cli org.jenkins-ci.main:cli:2.263.1 The MIT license
I am not sure what to tell you more. Let me know if you need more information.
A quick note on debugging!
Login to your jenkins machine and perform the same steps.
Let us see if you're able to do so? If yes try the same steps in jenkins windows batch command.
If no then you're doing something wrong with the command.
What do you mean by "it does not show at all that npm run build has bee executed." Do you find the build folder if yes then it's working file. Did you check jenkins build job console? if not pls check out the logs.
I figured it out. The problem was with package.json file. I delete it, deleted the node_modules folder and then I ran:
- npm install
- npm run build
then everything went smooth.
What exactly was wrong with package.json am not sure as it look OK to me.

Deploying ReactJs app in my machine through localhost

I create a reactJs App. But for now I run this app through Intellij idea and I would like to deploy it and run permanently in my machine without turning on through Intellij idea. How I could deploy react app and run it as deployment in my machine
If you created your app with create-react-app, you should be able to start local development server from the command line. To do this, open you project's root directory in the terminal and type npm start.
If you would like to create and serve a production bundle, you should build your project with npm run build and then serve build directory with a web server. The easiest way to do this is install serve via npm (npm install -g serve) and run serve -s build
For this purpose only webservers available like Tomcat, Payara, Whildfly, etc. You can install any one of those servers and deploy your application into that. As on when you started the server your application will be accessible.
Approach 1:
You can set up the server into your IDE and simply run the project on server mode.
Approach 2:
By using your project code, create a war file with the help of any build tool like MAVEN/GRADLE, etc. Then login into the server manager(Tomcat Manager) and deploy the generated .war file in deployment section.
Note: With the 2nd approach, you can access the application as on when you start the server.

Why do I need to install node.js and git to learn AngularJS?

I am presently reading Manning's AngularJS in Action by Lukas Ruebbelke
The introductory part suggests,
Because you’re pulling files from a CDN, you’ll need to run
Angello Lite(the application name) from a web server. There are a few ways to do this, but one of the easiest ways is to use the npm package serve.
The steps for installing Angello Lite are as follows:
■ Install Node.js. You can find all of the information to do that at http://
nodejs.org/.
■ Install the serve package by running npm install -g serve from the command
line.
■ Download Angello Lite from GitHub, using the URL given above, and place it
on your local machine in a directory named angello-lite.
■ Navigate to the angello-lite directory from the command line and run serve.
■ Go to http://localhost:3000 in your browser to see the application.
Does learning Angular JS require previous exposure to node and git?
If I have Apache Tomcat already configured on my local m/c, what is the procedure to start with it?
Furthermore, just to keep in sync with the author, I installed git and then cloned a dir onto my local m/c from github.
Then i install node.js and Install the serve package by runningnpm install -g servefrom the command line.
Unfortunately when i navigate to the angello-lite directory from the command line and run serve, it shows me
where angello-lite is the repository where the application resides?
Any suggestions on how to configure successfully?
I have no idea regarding node.js and git. Do i really need to learn
these to begin with AngularJS then.
No, that's not a requirement. You don't even need a web server. You can have your static HTML files locally or use some online service like plnkr. Obviously if you need to work with dynamic data then you will need a web server. At some point you might want to start making AJAX calls in order to fetch some dynamic data from your server backend.
If I have Apache Tomcat already configured on my local m/c, what is
the procedure to start with it?
Just add an HTML page to the root of your website, open your favorite browser and invoke this page.
You don't need those tools to learn Angular - you can download latest package from the AngularJS website (both for development and for production).
Node.js and Git may be necessary to pull and build packages from the NPM, run tasks and many more great features, but just to learn Angular all you need is its code.

Grails Migrations Plugin

I have an issue with the Grails Migrations plugin (version 1.3.2). I have a changelog setup of groovy files to run, however when I run "dbm-update" and the database is already populated, the command errors out FROM JENKINS. If I run the same command from my local machine, "dbm-update" just immediately finished because the database is already up-to-date.
From what I read and how I understand it to work, "dbm-update" should run any changesets that have not been run yet. I don't know why Jenkins would behave differently. And just to note, I'm using the grails wrapper to build on jenkins and I did test "dbm-update" with the grails wrapper on my local machine and it is working properly.

Resources