1
votes

I'm trying to create a Jenkins Pipeline or group of itens to help me create a custom CI/CD for my projects and right now i'm stuck at the deploy part, i want to deploy on the same server that my jenkins is running (Windows Server/IIS). I would also like to know how to deploy to another server (Windows Server/IIS), this second one would be my production env.

I have managed to clone, build and archive using two approaches with Jenkins:

  • Pipelines I have managed to create a pipeline that will clone my project, execute my build and then archive the artifacts from my build. The problem is, how do i deploy the artifact now?

This is my pipeline script

node {
   stage('git clone') {
      // Get some code from a GitHub repository
      git 'my-git-url'
   }
   stage('npm install') {
      bat label: 'npm install',
      script: '''cd app
        npm install'''
   }
   stage('gulp install') {
      bat label: 'gulp install',
      script: '''cd app
      npm i gulp'''
   }
   stage('gulp production') {
      bat label: 'gulp production',
      script: '''cd app
      gulp production'''
   }
   stage('create artifact') {
      archiveArtifacts artifacts: 'app/dist/**',
      onlyIfSuccessful: true
   }
}
  • Freestyle projects I have managed to create a project that will build and then archive the artifact using Execute shell build step and the Archive the artifacts post-build actions. How can i deploy the artifact using this approach? On this case i'm trying to trigger a second freestyle project to execute the deploy.
1
What is the result of your build commands? A bunch of css, fonts, js and index.html? - JRichardsz
@JRichardsz Yes, right now i'm only building the frontend, i will also need to later build my .net api and send some of it's files over. - Ariel
Ok. Do you need to deploy the css, fonts, js and index.html in your IIS using Jenkins? - JRichardsz
Yes, as i mentioned both servers use IIS - Ariel
In order to serve your static assets (css, fonts, js and index.html), you just need a basic http server like : apache, nginx, nodejs, etc. Are you able to config this on your IIS server : atlantic.net/hipaa-compliant-hosting/… ?? - JRichardsz

1 Answers

0
votes

According to your question : "I want to deploy on the same server that my jenkins is running (Windows Server/IIS)" .. and comments I will suggest some approaches.

Windows

Use windows as operative system for production environments is not recommended. Linux is the only and the best choice.

IIS

I don't recommed IIS to deploys static assets. You need something more light and scalable. You could use :

Deploy on IIS

Deploy static assets on IIS is just copy and paste the files on some folder and point IIS configurations to that folder:

Basic deploy on IIS using Jenkins

After your build commands, you just need to copy the build results (css.js.html.etc) and paste to some folder like c://webapps/my-app (pre-configured in IIS).

You can do this using a simple shell execution in free style project or pipeline script like https://stackoverflow.com/a/53159387/3957754

You could use this approach to deploy your static assets on the same server that your jenkins is running.

Advanced deploy on IIS using Jenkins

Microsoft has a tool called MSDeploy. Basically is a command line tool to deploy apps on remote IIS:

msdeploy.exe -verb:sync -source:contentPath="" -dest:contentPath=""

More details here:

Note: You can't run MS deploy commands that talk to the MSDeploy service on the same machine

Jenkins Agent

Jenkins agent is an application that runs on a remote server, not where jenkins master node runs.

Your master jenkins could use an agent in the remote or localhost IIS and execute jenkins jobs with copy and paste approach.