Jenkins-小记

Jenkins - 项目配置(前端)

构建 - Execute shell

bash 复制代码
yarn config set registry https://registry.npm.taobao.org -g
source /etc/profile
case $Project in
   PC)
   echo "Project:$Project"
   path="${WORKSPACE}/pc"
   cd $path
   yarn install
   yarn run build
   \cp -rf dist /usr/Web/xxxx/pc
   tar -zcvf ./html.tar.gz ./dist/*
   \cp html.tar.gz ${WORKSPACE}/new
   cd ${WORKSPACE}
   tar -zcvf ./new.tar.gz ./new/*
   ;;
  H5)
    echo "Project:$Project"
    path="${WORKSPACE}/h5"	
    cd $path
    yarn install
    yarn run build
    \cp -rf dist /usr/Web/xxxx/h5
    tar -zcvf ./h5.tar.gz ./dist/*
    \cp h5.tar.gz ${WORKSPACE}/new
    cd ${WORKSPACE}
    tar -zcvf ./new.tar.gz ./new/*
    exit
  ;;
esac

构建后操作 - Send build artifacts over SSH

Exec command
bash 复制代码
cd /usr/XXXX/Web/bak
mkdir "$(date +%Y-%m-%d-%H-%M)" && mv -f ../html "$(date +%Y-%m-%d-%H-%M)"
cd /usr/XXXX/Web
tar -zxvf new.tar.gz
cd /usr/XXXX/Web/new
tar -zxvf h5.tar.gz
mv dist h5
tar -zxvf html.tar.gz
mv dist html
mv -f h5 html
mv -f html /usr/XXXX/Web
#保留5个备份
ReservedNum=5  
FileDir=/usr/XXXX/Web/bak
date=$(date "+%Y-%m-%d-%H-%M")
cd $FileDir   
FileNum=$(ls -l | grep '^d' | wc -l)   
while(( $FileNum > $ReservedNum))
do
    OldFile=$(ls -rt | head -1)         
    echo  $date "Delete File:"$OldFile
    rm -rf $FileDir/$OldFile
    let "FileNum--"
done

Jenkins - 项目配置(后端-java)

1.General-描述

xxx系统后端发版

2.源码管理

Repository URL:
ruby 复制代码
http://127.0.0.1:8080/xxxx/java-service/xxx-system.git  
Credentials
Branches to build

指定分支

3.构建触发器

不设置

4.构建环境

选择Add timestamps to the Console Output

4.1 Pre Steps

不设置

4.2 Build
4.2.1 Root POM

pom.xml

4.2.2 Goals and options
ini 复制代码
clean package -Dmaven.test.skip=true
4.2.3 Post Steps

选择 Run only if build succeeds

5. 构建后操作

5.1Send build artifacts over SSH

SSH Server 下拉选择服务

Transfers Transfer Set Source files

perl 复制代码
xxxx-system-starter/target/xxxx-system-starter-1.0.0-SNAPSHOT.jar

Remote directory

bash 复制代码
/usr/XXXX/java

Exec command

bash 复制代码
cd /usr/xxxx/java/bak
mkdir "$(date +%Y-%m-%d-%H-%M)" && mv -f /usr/xxxx/java/xxxx-system-starter-1.0.0-SNAPSHOT.jar "$(date +%Y-%m-%d-%H-%M)"
cd /usr/xxxx/java/
cp -r xxxx-system-starter/target/xxxx-system-starter-1.0.0-SNAPSHOT.jar /usr/xxxx/java
rm -rf xxxx-system-starter
/usr/xxxx/script/xxxx-system.sh
#保留5个备份
ReservedNum=5  
FileDir=/usr/xxxx/java/bak
date=$(date "+%Y%m%d-%H%M%S")
cd $FileDir   
FileNum=$(ls -l | grep '^d' | wc -l)   
while(( $FileNum > $ReservedNum))
do
    OldFile=$(ls -rt | head -1)         
    echo  $date "Delete File:"$OldFile
    rm -rf $FileDir/$OldFile
    let "FileNum--"
done

Jenkins - Maven Settings

xml 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<localRepository>/usr/repository</localRepository>
	<interactiveMode>true</interactiveMode>
    <offline>false</offline>
    <pluginGroups>
        <pluginGroup>org.mortbay.jetty</pluginGroup>
        <pluginGroup>org.jenkins-ci.tools</pluginGroup>
    </pluginGroups>
	
	<!--配置权限,使用默认用户-->
	<servers>
		<server>
			<id>nexus-releases</id>
			<username>deployment</username>
			<password>deployment123</password>
		</server>
		<server> 
			<id>nexus-snapshots</id>
			<username>deployment</username>
			<password>deployment123</password>
		</server>
	</servers>

  <mirrors>
 	 <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
  </mirrors>

	<profiles>
		<profile>
		   <id>XXXX</id>
			    <activation>
                    <activeByDefault>false</activeByDefault>
                    <jdk>1.8</jdk>
                </activation>
			    <repositories>
					<!-- 私有库地址-->
				    <repository>
						<id>nexus</id>
						
						<releases>
							<enabled>true</enabled>
						</releases>
						<snapshots>
							<enabled>true</enabled>
						</snapshots>
					</repository>
				</repositories>      
				<pluginRepositories>
					<!--插件库地址-->
					<pluginRepository>
						<id>nexus</id>
						
						<releases>
							<enabled>true</enabled>
						</releases>
						<snapshots>
							<enabled>true</enabled>
					   </snapshots>
					</pluginRepository>
				</pluginRepositories>
			</profile>
	</profiles>
	
	<!--激活profile-->
	<activeProfiles>
		<activeProfile>XXXX</activeProfile>
	</activeProfiles>
	
</settings>
相关推荐
轻口味17 分钟前
【每日学点鸿蒙知识】AVCodec、SmartPerf工具、web组件加载、监听键盘的显示隐藏、Asset Store Kit
前端·华为·harmonyos
alikami19 分钟前
【若依】用 post 请求传 json 格式的数据下载文件
前端·javascript·json
吃杠碰小鸡1 小时前
lodash常用函数
前端·javascript
emoji1111111 小时前
前端对页面数据进行缓存
开发语言·前端·javascript
泰伦闲鱼1 小时前
nestjs:GET REQUEST 缓存问题
服务器·前端·缓存·node.js·nestjs
m0_748250031 小时前
Web 第一次作业 初探html 使用VSCode工具开发
前端·html
一个处女座的程序猿O(∩_∩)O1 小时前
vue3 如何使用 mounted
前端·javascript·vue.js
m0_748235951 小时前
web复习(三)
前端
AiFlutter1 小时前
Flutter-底部分享弹窗(showModalBottomSheet)
java·前端·flutter
麦兜*1 小时前
轮播图带详情插件、uniApp插件
前端·javascript·uni-app·vue