zoukankan      html  css  js  c++  java
  • JenKins使用pm2部署.net core网站

    登录事先准备好的 Jenkins

    • 1 新建任务

    • 2 源码管理 git 输入正确地址

    • 3 构建环境:
      Delete workspace before build starts
      Abort the build if it's stuck

      打勾

    • 4 安装事先准备好的 pm2
      打开shell安装
      参考 https://www.cnblogs.com/stulzq/p/9775973.html

    sudo yum install nodejs
    node -v

    npm install pm2 -g

    • 5 回到Jenkins
      选择 构建=>执行shell

     

    ls
    cd ./VPStest.netCore/VPStest.netCore
    ls
    
    dotnet publish -c Release
    cd bin/Release/netcoreapp2.2/publish
    ls
    pm2 start "dotnet VPStest.netCore.dll" --name testweb
    
    • 6 保存
    • 选择立即构建

    • 7 查看控制台输出

     

    Started by user www
    Building in workspace /var/lib/jenkins/workspace/DotCoreTest
    [WS-CLEANUP] Deleting project workspace...
    [WS-CLEANUP] Deferred wipeout is used...
    [WS-CLEANUP] Done
    No credentials specified
    Cloning the remote Git repository
    Cloning repository https://github.com/www/VPStest.git
    > git init /var/lib/jenkins/workspace/DotCoreTest # timeout=10
    Fetching upstream changes from https://github.com/www/VPStest.git
    > git --version # timeout=10
    > git fetch --tags --progress https://github.com/www/VPStest.git +refs/heads/*:refs/remotes/origin/*
    > git config remote.origin.url https://github.com/www/VPStest.git # timeout=10
    > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
    > git config remote.origin.url https://github.com/www/VPStest.git # timeout=10
    Fetching upstream changes from https://github.com/www/VPStest.git
    > git fetch --tags --progress https://github.com/www/VPStest.git +refs/heads/*:refs/remotes/origin/*
    > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
    > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
    Checking out Revision 66cec8d481afee09a71ab9941e2ce25db6075485 (refs/remotes/origin/master)
    > git config core.sparsecheckout # timeout=10
    > git checkout -f 66cec8d481afee09a71ab9941e2ce25db6075485
    Commit message: "修改"
    > git rev-list --no-walk 66cec8d481afee09a71ab9941e2ce25db6075485 # timeout=10
    [DotCoreTest] $ /bin/sh -xe /tmp/jenkins8834327214949599471.sh
    + ls
    DockerCompsoe
    LICENSE
    README.md
    VPStest.netCore
    + cd ./VPStest.netCore/VPStest.netCore
    + ls
    appsettings.Development.json
    appsettings.json
    Controllers
    Dockerfile
    Models
    Program.cs
    Startup.cs
    Views
    VPStest.netCore.csproj
    wwwroot
    + dotnet publish -c Release
    Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
    Copyright (C) Microsoft Corporation. All rights reserved.

    Restoring packages for /var/lib/jenkins/workspace/DotCoreTest/VPStest.netCore/VPStest.netCore/VPStest.netCore.csproj...
    Generating MSBuild file /var/lib/jenkins/workspace/DotCoreTest/VPStest.netCore/VPStest.netCore/obj/VPStest.netCore.csproj.nuget.g.props.
    Generating MSBuild file /var/lib/jenkins/workspace/DotCoreTest/VPStest.netCore/VPStest.netCore/obj/VPStest.netCore.csproj.nuget.g.targets.
    Restore completed in 1.81 sec for /var/lib/jenkins/workspace/DotCoreTest/VPStest.netCore/VPStest.netCore/VPStest.netCore.csproj.
    VPStest.netCore -> /var/lib/jenkins/workspace/DotCoreTest/VPStest.netCore/VPStest.netCore/bin/Release/netcoreapp2.2/VPStest.netCore.dll
    VPStest.netCore -> /var/lib/jenkins/workspace/DotCoreTest/VPStest.netCore/VPStest.netCore/bin/Release/netcoreapp2.2/VPStest.netCore.Views.dll
    VPStest.netCore -> /var/lib/jenkins/workspace/DotCoreTest/VPStest.netCore/VPStest.netCore/bin/Release/netcoreapp2.2/publish/
    + cd bin/Release/netcoreapp2.2/publish
    + ls
    appsettings.Development.json
    appsettings.json
    VPStest.netCore.deps.json
    VPStest.netCore.dll
    VPStest.netCore.pdb
    VPStest.netCore.runtimeconfig.json
    VPStest.netCore.Views.dll
    VPStest.netCore.Views.pdb
    web.config
    wwwroot
    + pm2 start 'dotnet VPStest.netCore.dll' --name testweb
    [PM2] Starting /bin/bash in fork_mode (1 instance)
    [PM2] Done.
    ┌──────────┬────┬─────────┬──────┬───────┬────────┬─────────┬────────┬─────┬────────────┬──────┬──────────┐
    │ App name │ id │ version │ mode │ pid │ status │ restart │ uptime │ cpu │ mem │ user │ watching │
    ├──────────┼────┼─────────┼──────┼───────┼────────┼─────────┼────────┼─────┼────────────┼──────┼──────────┤
    │ sffweb │ 0 │ N/A │ fork │ 10209 │ online │ 0 │ 33m │ 0% │ 116.3 MB │ root │ disabled │
    │ testweb │ 1 │ N/A │ fork │ 13650 │ online │ 0 │ 0s │ 0% │ 3.8 MB │ root │ disabled │
    └──────────┴────┴─────────┴──────┴───────┴────────┴─────────┴────────┴─────┴────────────┴──────┴──────────┘
    Use `pm2 show <id|name>` to get more details about an app
    Finished: SUCCESS
      • 8 开放 5000 端口

        sudo firewall-cmd --add-port=5000/tcp

      • 9 打开浏览器 输入 IP:5000 成功

  • 相关阅读:
    MySQL简介
    MySQL表及索引相关知识
    关系型和非关系型数据库
    IntelliSense: #error 指令: Please use the /MD switch for _AFXDLL builds————c++编程问题
    msvcrt是做什么的
    COLORREF的结构和用法
    虚函数这么用,只要有一个基类的指针就行了
    映射的磁盘(网络驱动器)无法显示svn图标
    as3 textfield 旋转文字有锯齿的问题
    cocos2dx中CCFileUtils::sharedFileUtils()>getFileData的内存释放问题
  • 原文地址:https://www.cnblogs.com/WNpursue/p/10646725.html
Copyright © 2011-2022 走看看