我正在尝试创建Jenkins管道或itens组,以帮助我为我的项目创建自定义CI / CD,现在我停留在部署部分,我想在与我相同的服务器上进行部署jenkins正在运行(Windows Server / IIS)。我还想知道如何部署到另一台服务器(Windows Server / IIS),这第二台服务器将是我的生产环境。
我已经成功使用Jenkins的两种方法克隆,构建和归档了
这是我的管道脚本
WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException
javax.xml.ws.WebServiceException:
org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:344)
at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:337)
at javax.xml.ws.Service.getPort(Unknown Source)
at com.visanet.main.ServiceObjectFactory.getServiceByObject(ServiceObjectFactory.java:54)
at com.visanet.controllers.CheckUserController.checkUser(CheckUserController.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:189)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
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
}
}
的构建步骤和Execute shell
的构建后操作进行构建,然后将其归档。如何使用这种方法部署工件?在这种情况下,我试图触发另一个自由式项目来执行部署。答案 0 :(得分:0)
根据您的问题:“我想在我的jenkins正在运行的同一台服务器上部署(Windows Server / IIS)” .. 并提出一些建议。
不建议将Windows用作生产环境的操作系统。 Linux是唯一的最佳选择。
我不建议IIS部署静态资产。您需要更轻便和可扩展的产品。您可以使用:
在IIS上部署静态资产仅仅是复制并粘贴文件到某些文件夹,并将IIS配置指向该文件夹:
在执行构建命令后,您只需复制构建结果(css.js.html.etc),然后粘贴到某些文件夹,例如 c: // webapps / my-app (已在IIS中预先配置)。
您可以在自由样式项目中使用简单的shell执行或使用https://stackoverflow.com/a/53159387/3957754
这样的管道脚本来执行此操作您可以使用这种方法在您的jenkins正在运行的同一台服务器上部署静态资产。
Microsoft有一个名为 MSDeploy 的工具。基本上是用于在远程 IIS上部署应用程序的命令行工具:
msdeploy.exe -verb:sync -source:contentPath="" -dest:contentPath=""
更多详细信息在这里:
注意: You can't run MS deploy commands that talk to the MSDeploy service on the same machine
Jenkins代理是在远程服务器上运行的应用程序,而不是在jenkins主节点运行的地方。
您的主詹金斯可以使用远程或本地IIS中的代理,并通过复制和粘贴方法执行詹金斯作业。