Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B 12111644 #36

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 108 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// pipeline {
// agent any
// stages {
// stage('Build') {
// steps {
// sh 'mvn -B -DskipTests clean package'
// }
// }
// stage('Test') {
// steps {
// sh 'mvn test --fail-never'
// }
// }
// stage('doc') {
// steps {
// sh 'mvn javadoc:javadoc --fail-never'
// }
// }
// stage('pmd') {
// steps {
// sh 'mvn pmd:pmd'
// }
// }
// stage('Test report') {
// steps {
// sh 'mvn jacoco:report'
// sh 'mvn surefire-report:report'
// }
// }



// }
// post {
// always {
// archiveArtifacts artifacts: '**/target/site/**', fingerprint: true
// archiveArtifacts artifacts: '**/target/**/*.jar', fingerprint: true
// archiveArtifacts artifacts: '**/target/**/*.war', fingerprint: true
// }
// }
// }


pipeline {
agent any

environment {
// 你的Docker仓库的凭证ID
DOCKER_CREDENTIALS_ID = 'nihao'
// 你想要推送的镜像名字
IMAGE_NAME = 'mxxx667/teedy_re'
// 标签,可以根据实际情况设置
TAG = 'v1.0'
}

stages{
stage('Package') {
steps {
checkout scm
sh 'mvn -B -DskipTests clean package'

}
}

stage('Build Image') {
steps {
// 使用Docker命令构建镜像
sh " sudo docker build -t ${IMAGE_NAME}:${TAG} -f Dockerfile ."
}
}

stage('Push Image') {
steps {
// 登录Docker Hub
withCredentials([usernamePassword(credentialsId: DOCKER_CREDENTIALS_ID, usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
// 使用Docker命令登录
sh " sudo docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}"
// 使用Docker命令推送镜像
sh "sudo docker push ${IMAGE_NAME}:${TAG}"
}
}
}

// 添加一个阶段来停止和移除之前的容器
stage('Stop and Remove Previous Containers') {
steps {
// 停止并移除名为teedy_01的容器
sh " sudo docker stop teedy_01 || true"
sh " docker rm teedy_01 || true"
// 停止并移除名为teedy_02的容器
sh "sudo docker stop teedy_02 || true"
sh "sudo docker rm teedy_02 || true"
// 停止并移除名为teedy_03的容器
sh " sudo docker stop teedy_03 || true"
sh " sudo docker rm teedy_03 || true"
}
}
//Running Docker container
stage('Run containers'){
steps{
sh 'sudo docker run -d -p 8084:8080 --name teedy_01 ${IMAGE_NAME}:${TAG}'
sh 'sudo docker run -d -p 8082:8080 --name teedy_02 ${IMAGE_NAME}:${TAG}'
sh 'sudo docker run -d -p 8083:8080 --name teedy_03 ${IMAGE_NAME}:${TAG}'

}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,12 @@ public void testJpa() throws Exception {

// Authenticate using the database
Assert.assertNotNull(new InternalAuthenticationHandler().authenticate("username", "12345678"));
userDao.delete("username", "me");
TransactionUtil.commit();
user=userDao.getById(id);

Assert.assertNotNull(user.getDeleteDate());
}


}
Binary file modified docs-web/src/main/webapp/src/img/title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion docs-web/src/main/webapp/src/partial/docs/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,14 @@
ng-attr-placeholder="{{ 'login.validation_code' | translate }}" ng-model="user.code" />
</div>

<!--
<div class="checkbox text-muted">
<label>
<input type="checkbox" ng-model="user.remember" name="remember" /> {{ 'login.remember_me' | translate }}
</label>
</div>
-->


<div class="row">
<div class="col-md-6">
Expand All @@ -85,4 +88,4 @@
</div>

<div class="login-img-container col-sm-6 hidden-xs"></div>
</div>
</div>
84 changes: 81 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,19 @@

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${org.apache.maven.plugins.maven-antrun-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>4.0.0-M13</version>
</plugin>


<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -105,18 +113,63 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${org.apache.maven.plugins.maven-surefire-plugin.version}</version>
<version>3.0.0</version>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<excludes>
<exclude>**/TestJpa.java</exclude>
</excludes>
</configuration>
</plugin>


<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${org.eclipse.jetty.jetty-maven-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.21.2</version> <!-- or use version from pluginManagement -->
<configuration>
<!-- failOnViolation is actually true by default, but can be disabled -->
<failOnViolation>false</failOnViolation>
<!-- printFailingErrors is pretty useful -->
<printFailingErrors>true</printFailingErrors>
<rulesets>
<ruleset>/practice-answer.xml</ruleset>
</rulesets>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.9</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -504,5 +557,30 @@

</dependencies>
</dependencyManagement>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<reportSets>
<reportSet>
<id>aggregate</id>
<inherited>false</inherited>
<reports>
<report>aggregate</report>
</reports> </reportSet>
<reportSet>
<id>default</id>
<reports>
<report>javadoc</report>
</reports>
</reportSet>
</reportSets>
</plugin>

</plugins>
</reporting>

</project>
20 changes: 20 additions & 0 deletions practice-answer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>

<ruleset name="Custom Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">

<description>
<!-- My custom rules-->

</description>

<rule ref="category/java/design.xml/CouplingBetweenObjects" />
<rule ref="category/java/design.xml/CyclomaticComplexity" />
<rule ref="category/java/design.xml/NcssCount" />
<rule ref="category/java/design.xml/GodClass" />

<!-- Your rules will come here -->

</ruleset>