| .gitignore | ●●●●● patch | view | raw | blame | history | |
| Jenkinsfile | ●●●●● patch | view | raw | blame | history | |
| gitflow-installer.sh | ●●●●● patch | view | raw | blame | history | |
| pom.xml | ●●●●● patch | view | raw | blame | history | |
| src/main/java/git_study.java | ●●●●● patch | view | raw | blame | history | |
| src/main/webapp/WEB-INF/web.xml | ●●●●● patch | view | raw | blame | history | |
| src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java | ●●●●● patch | view | raw | blame | history | |
| test.js | ●●●●● patch | view | raw | blame | history |
.gitignore
@@ -11,3 +11,7 @@ # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* /.idea/ gitflow-installer.sh target/ **/target/ *.iml Jenkinsfile
@@ -10,6 +10,7 @@ } options { //给日志加上时间错, 需安装 Timestamper 插件 //mvn test surefire-report:report timestamps() ansiColor('xterm') //丢弃旧的构建前两个为发布包保留天数(比此早的发布包将被删除,但构建的日志、操作历史、报告等将被保留)和构建个数 @@ -29,13 +30,45 @@ } } stage('test') { stage('testMaven') { steps { sh 'mvn clean test -U' junit allowEmptyResults: true, keepLongStdio: true, skipPublishingChecks: true, testResults: 'target/surefire-reports/*.xml' } } stage('testFunction') { steps { sh 'echo test' } } //将项目打成war并归档,将配置文件目录存入stash stage('package') { steps { sh '''#!/bin/sh ####maven编译部署##### mvn clean package -U ##处理结果包 old_version_all=\$(find . -iname "\${project_name}.java"| xargs sed -nr 's/^[^0-9]*\\"(([0-9]+\\.)*[0-9]+.*-[0-9]+)\\".*;/\\1/p\') echo "old_version_all \$old_version_all" echo "project_name \$project_name" dir_name=\${project_name}"-"\$old_version_all echo "dir_name \$dir_name" cd target mkdir \$dir_name cp *.war \$dir_name zip -r "\$dir_name.zip" \$dir_name ''' } } stage('version add') { when { //版本号自动添加逻辑需同时符合下列触发条件: //1. 不能在master分支触发 //2. 有任意浏览器页面资源文件修改 //3. 不包含[项目名.java]文件的修改 allOf { not { branch 'master' @@ -53,10 +86,9 @@ } } } steps{ echo "todo add version" steps { versionAddTest("${project_name}","${GIT_CREDENTIALS_ID}","${url}","${GIT_BRANCH}") } } stage('deploy') { when { branch 'master' } gitflow-installer.sh
New file @@ -0,0 +1,117 @@ #!/bin/bash # git-flow make-less installer for *nix systems, by Rick Osborne # Based on the git-flow core Makefile: # http://github.com/petervanderdoes/gitflow-avh/blob/master/Makefile # Licensed under the same restrictions as git-flow: # http://github.com/petervanderdoes/gitflow-avh/blob/develop/LICENSE # Updated for the fork at petervanderdoes usage() { echo "Usage: [environment] gitflow-installer.sh [install|uninstall] [stable|develop|version] [tag]" echo "Environment:" echo " PREFIX=$PREFIX" echo " REPO_HOME=$REPO_HOME" echo " REPO_NAME=$REPO_NAME" exit 1 } # Does this need to be smarter for each host OS? if [ -z "$PREFIX" ] ; then PREFIX="/usr/local" fi if [ -z "$REPO_NAME" ] ; then REPO_NAME="gitflow" fi if [ -z "$REPO_HOME" ] ; then REPO_HOME="https://github.com/petervanderdoes/gitflow-avh.git" fi EXEC_PREFIX="$PREFIX" BINDIR="$EXEC_PREFIX/bin" DATAROOTDIR="$PREFIX/share" DOCDIR="$DATAROOTDIR/doc/gitflow" EXEC_FILES="git-flow" SCRIPT_FILES="git-flow-init git-flow-feature git-flow-bugfix git-flow-hotfix git-flow-release git-flow-support git-flow-version gitflow-common gitflow-shFlags git-flow-config" HOOK_FILES="$REPO_NAME/hooks/*" echo "### git-flow no-make installer ###" case "$1" in uninstall) echo "Uninstalling git-flow from $PREFIX" if [ -d "$BINDIR" ] ; then for script_file in $SCRIPT_FILES $EXEC_FILES ; do echo "rm -vf $BINDIR/$script_file" rm -vf "$BINDIR/$script_file" done rm -rf "$DOCDIR" else echo "The '$BINDIR' directory was not found." fi exit ;; help) usage exit ;; install) if [ -z $2 ]; then usage exit fi echo "Installing git-flow to $BINDIR" if [ -d "$REPO_NAME" -a -d "$REPO_NAME/.git" ] ; then echo "Using existing repo: $REPO_NAME" else echo "Cloning repo from GitHub to $REPO_NAME" git clone "$REPO_HOME" "$REPO_NAME" fi cd "$REPO_NAME" git pull cd "$OLDPWD" case "$2" in stable) cd "$REPO_NAME" git checkout master cd "$OLDPWD" ;; develop) cd "$REPO_NAME" git checkout develop cd "$OLDPWD" ;; version) cd "$REPO_NAME" git checkout tags/$3 cd "$OLDPWD" ;; *) usage exit ;; esac install -v -d -m 0755 "$PREFIX/bin" install -v -d -m 0755 "$DOCDIR/hooks" for exec_file in $EXEC_FILES ; do install -v -m 0755 "$REPO_NAME/$exec_file" "$BINDIR" done for script_file in $SCRIPT_FILES ; do install -v -m 0644 "$REPO_NAME/$script_file" "$BINDIR" done for hook_file in $HOOK_FILES ; do install -v -m 0644 "$hook_file" "$DOCDIR/hooks" done exit ;; *) usage exit ;; esac pom.xml
New file @@ -0,0 +1,42 @@ <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.hbbohua</groupId> <artifactId>git_study</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13</version> <scope>test</scope> </dependency> </dependencies> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <!--当前项目版本号--> <revision>1.9.0-SNAPSHOT</revision> <maven.deploy.skip>true</maven.deploy.skip> </properties> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <testFailureIgnore>true</testFailureIgnore> </configuration> </plugin> </plugins> </build> </project> src/main/java/git_study.java
New file @@ -0,0 +1,18 @@ /** * 测试项目<br> */ public class git_study { /** * 保证每次打包发现场部署时增长(目前仅增长末位 +1) */ String version = "1.9.0-SNAPSHOT-1"; /** * 获取版本号。可用于前端资源引用版本化,解决浏览器缓存问题。 * * @return 版本号 */ public String getVersion() { return version; } } src/main/webapp/WEB-INF/web.xml
New file @@ -0,0 +1,10 @@ <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> </web-app> src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java
New file @@ -0,0 +1,10 @@ package com.hbbohua.gitStudy; import org.junit.Test; public class HelloWorldTest { @Test public void test1(){ System.out.println("hello test...."); } } test.js
@@ -1,13 +0,0 @@ test.fsdf 1 hotfix_version1_0_2 bug:detail merge:fast-forward 12 gittest.fsdf feature1 123