jenkins編譯源碼和發布網站


一、JAVA程序

1.新建任務(可復制vcl-master-test)

 

2.配置

 

填寫發布版本的URL和分支

 

 

 

用maven打包,只有一個項目填clean package -DskipTests

多項目寫clean package -DskipTests -pl vcl-service -am

 

這里配密鑰對,做免密登錄,方法自行百度

 

#!/bin/bash

#目標機器信息:用戶,ip,jar包名,jekins包路徑,目標機器路徑

remote_user="root"

remote_ip="10.138.60.76"

jar_file="vcl-master.jar"

local_path="vcl-master/target"

remote_path="/data/vcredit-vcl"

release_path="$remote_path"

backup_path="$remote_path/backup"

 

#殺已啟動jar進程

ssh $remote_user@$remote_ip "ps -ef | grep $jar_file | grep -v grep | cut -c 9-15 | xargs kill -9"

 

#目標機器舊jar備份

if [ $? -eq 0 ]; then

    ssh $remote_user@$remote_ip "mv $release_path/$jar_file $backup_path/$jar_file.`date +%Y-%m-%d-%k-%M`"

fi

 

#復制jekins包到目標機器

if [ $? -eq 0 ]; then

    scp $local_path/$jar_file $remote_user@$remote_ip:$release_path/

fi

 

#目標機器啟動jar並日志重定向

if [ $? -eq 0 ]; then

    ssh $remote_user@$remote_ip "cd $release_path ; java -jar $jar_file > $remote_path/out.log 2>&1 &"

fi

 

#在目標機上打印最后50行日志

if [ $? = 0 ]; then

    sleep 30

    ssh $remote_user@$remote_ip "tail -n 50 $remote_path/out.log"

fi

3.配置完就可以構建了

 

二、.net程序

首先需要安裝MSBuild和Nuget

.net有兩種方式:

1.編譯源碼

2.發布網站(接口)

 

1.編譯源碼

 D:\jenkins\workspace\nuget.exe restore "D:\jenkins\workspace\IR1419\VcreditOA.sln"

/t:Rebuild
/p:Configuration=Release
/p:TargetFrameworkVersion=v4.5
/p:VisualStudioVersion=12.0
/p:OutputPath=D:\jenkins\workspace\IR1419\dabao

 

2.發布網站

 D:\jenkins\workspace\nuget.exe restore "D:\jenkins\workspace\貸后\201912\PIT059\VBSBaseService\V3SService.sln"

/t:Rebuild
/t:ResolveReferences;Compile
/t:_CopyWebApplication
/p:Configuration=Release
/p:TargetFrameworkVersion=v4.5.1
/p:VisualStudioVersion=12.0
/p:WebProjectOutputDir=D:\jenkins\workspace\貸后\201912\PIT059\publish
/p:OutputPath=D:\jenkins\workspace\貸后\201912\PIT059\VBSBaseService\VBSBaseService\bin

 

x86方式需在配置添加  /p:Platform=x86

 

Jenkins插件更新站點  https://updates.jenkins.io/update-center.json

             http://mirror.xmission.com/jenkins/updates/update-center.json

 

MSBuild參數參考:

https://blog.csdn.net/jianzhiying/article/details/5291847


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM