diff --git a/Jenkinsfile b/Jenkinsfile index 36c4c31..643c996 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,17 +8,39 @@ pipeline { } stages { - stage('Pre') { + stage('Pull Code') { steps { - sshagent([env.SSH_CREDENTIALS_ID]) { - sh 'ssh alex@117.72.202.202 "bash /home/alex/alex-api/bin/pre-steps.sh"' + sshagent([env.SSH_CREDENTIALS_ID]) { + sh """ + ssh ${REMOTE_USER}@${REMOTE_HOST} ' + set -e + cd ${REMOTE_DIR} || git clone git@117.72.202.202:ALEX/alex-api.git ${REMOTE_DIR} + cd ${REMOTE_DIR} + git pull origin master + ' + """ + } + } + } + + stage('Pre Steps') { + steps { + sshagent([env.SSH_CREDENTIALS_ID]) { + sh "ssh ${REMOTE_USER}@${REMOTE_HOST} 'bash ${REMOTE_DIR}/bin/pre-steps.sh'" } } } stage('Build') { steps { - sh 'mvn clean package -DskipTests' + sshagent([env.SSH_CREDENTIALS_ID]) { + sh """ + ssh ${REMOTE_USER}@${REMOTE_HOST} ' + cd ${REMOTE_DIR} + mvn clean package -DskipTests + ' + """ + } } } @@ -26,16 +48,15 @@ pipeline { steps { sshagent([env.SSH_CREDENTIALS_ID]) { sh """ - scp target/alex-api-0.0.1-SNAPSHOT.jar ${REMOTE_USER}@${REMOTE_HOST}:${REMOTE_DIR}/app/ - ssh ${REMOTE_USER}@${REMOTE_HOST} ' - cd ${REMOTE_DIR} && - sudo docker compose down && - sudo docker compose up -d --build - ' + ssh ${REMOTE_USER}@${REMOTE_HOST} ' + cd ${REMOTE_DIR} + sudo docker compose down + sudo docker image prune -f + sudo docker compose up -d --build + ' """ } } } } } - diff --git a/app/alex-api-0.0.1-SNAPSHOT.jar b/app/alex-api-0.0.1-SNAPSHOT.jar index c6e030d..b4f6ca3 100755 Binary files a/app/alex-api-0.0.1-SNAPSHOT.jar and b/app/alex-api-0.0.1-SNAPSHOT.jar differ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e8e145a..11a9618 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -3,7 +3,7 @@ server: port: 8888 spring: profiles: - active: dev # 默认激活开发环境 + active: test #配置mybatis mybatis: configuration: @@ -38,4 +38,4 @@ logging: org: springframework: integration: DEBUG - messaging: DEBUG \ No newline at end of file + messaging: DEBUG diff --git a/target/alex-api-0.0.1-SNAPSHOT.jar b/target/alex-api-0.0.1-SNAPSHOT.jar new file mode 100644 index 0000000..d5be81a Binary files /dev/null and b/target/alex-api-0.0.1-SNAPSHOT.jar differ diff --git a/target/alex-api-0.0.1-SNAPSHOT.jar.original b/target/alex-api-0.0.1-SNAPSHOT.jar.original new file mode 100644 index 0000000..0e474fb Binary files /dev/null and b/target/alex-api-0.0.1-SNAPSHOT.jar.original differ diff --git a/target/classes/application-dev.yml b/target/classes/application-dev.yml new file mode 100644 index 0000000..5e58b5a --- /dev/null +++ b/target/classes/application-dev.yml @@ -0,0 +1,12 @@ +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://localhost:3306/test_alex?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true + username: root + password: ALEXzcz123456 + redis: + host: localhost + password: ALEXzcz123456 + port: 6379 + database: 0 \ No newline at end of file diff --git a/target/classes/application-prod.yml b/target/classes/application-prod.yml new file mode 100644 index 0000000..674c874 --- /dev/null +++ b/target/classes/application-prod.yml @@ -0,0 +1,12 @@ +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://117.72.202.202:3306/test_alex?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true + username: alex + password: ALEXzcz123456 + redis: + host: 117.72.202.202 + password: ALEXzcz123456 + port: 6379 + database: 0 \ No newline at end of file diff --git a/target/classes/application-test.yml b/target/classes/application-test.yml new file mode 100644 index 0000000..25e6375 --- /dev/null +++ b/target/classes/application-test.yml @@ -0,0 +1,12 @@ +spring: + datasource: + type: com.zaxxer.hikari.HikariDataSource + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://117.72.202.202:3306/test_alex?characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true + username: alex + password: ALEXzcz123456 + redis: + host: 117.72.202.202 + password: ALEXzcz123456 + port: 6379 + database: 0 diff --git a/target/classes/application.yml b/target/classes/application.yml new file mode 100644 index 0000000..11a9618 --- /dev/null +++ b/target/classes/application.yml @@ -0,0 +1,41 @@ +server: + address: 0.0.0.0 + port: 8888 +spring: + profiles: + active: test +#配置mybatis +mybatis: + configuration: + auto-mapping-behavior: full + map-underscore-to-camel-case: true + log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl + type-aliases-package: com.anytrek.entity # 配置别名路径 + mapper-locations: classpath:mapper/*.xml # 配置 XML 文件位置 +#配置mybatis-plus +mybatis-plus: + configuration: + log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl + global-config: + db-config: + table-prefix: t_ + id-type: auto +#配置分页插件 +pagehelper: + helperDialect: mysql + params: count=countSql + reasonable: true + supportMethodsArguments: true +#配置日志 +logging: + level: + root: INFO #根日志配置,整个应用程序的默认日志级别为 INFO + com.anytrek: DEBUG #com.anytrek 包下的类的日志级别设置为 DEBUG + org.apache.ibatis: INFO #MyBatis 日志级别设置为 INFO + com.zaxxer.hikari: INFO #HikariCP 的日志级别设置为 INFO + org.springframework.web.socket: DEBUG + org.springframework.web.socket.server.support: DEBUG + org: + springframework: + integration: DEBUG + messaging: DEBUG diff --git a/target/classes/com/ctgu/alexapi/AlexApiApplication.class b/target/classes/com/ctgu/alexapi/AlexApiApplication.class new file mode 100644 index 0000000..23a1ac7 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/AlexApiApplication.class differ diff --git a/target/classes/com/ctgu/alexapi/config/RedisConfig.class b/target/classes/com/ctgu/alexapi/config/RedisConfig.class new file mode 100644 index 0000000..97ff03c Binary files /dev/null and b/target/classes/com/ctgu/alexapi/config/RedisConfig.class differ diff --git a/target/classes/com/ctgu/alexapi/controller/UsersController.class b/target/classes/com/ctgu/alexapi/controller/UsersController.class new file mode 100644 index 0000000..5c3668e Binary files /dev/null and b/target/classes/com/ctgu/alexapi/controller/UsersController.class differ diff --git a/target/classes/com/ctgu/alexapi/entity/UsersEntity.class b/target/classes/com/ctgu/alexapi/entity/UsersEntity.class new file mode 100644 index 0000000..3d55435 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/entity/UsersEntity.class differ diff --git a/target/classes/com/ctgu/alexapi/mapper/UsersMapper.class b/target/classes/com/ctgu/alexapi/mapper/UsersMapper.class new file mode 100644 index 0000000..9972937 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/mapper/UsersMapper.class differ diff --git a/target/classes/com/ctgu/alexapi/service/UsersService.class b/target/classes/com/ctgu/alexapi/service/UsersService.class new file mode 100644 index 0000000..acf0405 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/service/UsersService.class differ diff --git a/target/classes/com/ctgu/alexapi/service/impl/UsersServiceImpl.class b/target/classes/com/ctgu/alexapi/service/impl/UsersServiceImpl.class new file mode 100644 index 0000000..f0f104c Binary files /dev/null and b/target/classes/com/ctgu/alexapi/service/impl/UsersServiceImpl.class differ diff --git a/target/classes/com/ctgu/alexapi/utils/ApiResult$ApiResultBuilder.class b/target/classes/com/ctgu/alexapi/utils/ApiResult$ApiResultBuilder.class new file mode 100644 index 0000000..afc774a Binary files /dev/null and b/target/classes/com/ctgu/alexapi/utils/ApiResult$ApiResultBuilder.class differ diff --git a/target/classes/com/ctgu/alexapi/utils/ApiResult.class b/target/classes/com/ctgu/alexapi/utils/ApiResult.class new file mode 100644 index 0000000..3186d46 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/utils/ApiResult.class differ diff --git a/target/classes/com/ctgu/alexapi/utils/PageData$PageDataBuilder.class b/target/classes/com/ctgu/alexapi/utils/PageData$PageDataBuilder.class new file mode 100644 index 0000000..797ea78 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/utils/PageData$PageDataBuilder.class differ diff --git a/target/classes/com/ctgu/alexapi/utils/PageData.class b/target/classes/com/ctgu/alexapi/utils/PageData.class new file mode 100644 index 0000000..8bea395 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/utils/PageData.class differ diff --git a/target/classes/com/ctgu/alexapi/utils/Tools.class b/target/classes/com/ctgu/alexapi/utils/Tools.class new file mode 100644 index 0000000..e4698e7 Binary files /dev/null and b/target/classes/com/ctgu/alexapi/utils/Tools.class differ diff --git a/target/classes/mapper/UsersMapper.xml b/target/classes/mapper/UsersMapper.xml new file mode 100644 index 0000000..6de296e --- /dev/null +++ b/target/classes/mapper/UsersMapper.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + id,username,password + + diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..b4f29da --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,3 @@ +artifactId=alex-api +groupId=com.ctgu +version=0.0.1-SNAPSHOT diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..ec086f8 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,12 @@ +com/ctgu/alexapi/utils/PageData.class +com/ctgu/alexapi/utils/ApiResult$ApiResultBuilder.class +com/ctgu/alexapi/controller/UsersController.class +com/ctgu/alexapi/utils/ApiResult.class +com/ctgu/alexapi/mapper/UsersMapper.class +com/ctgu/alexapi/utils/PageData$PageDataBuilder.class +com/ctgu/alexapi/AlexApiApplication.class +com/ctgu/alexapi/service/impl/UsersServiceImpl.class +com/ctgu/alexapi/utils/Tools.class +com/ctgu/alexapi/service/UsersService.class +com/ctgu/alexapi/config/RedisConfig.class +com/ctgu/alexapi/entity/UsersEntity.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..7ea56a5 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,10 @@ +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/mapper/UsersMapper.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/entity/UsersEntity.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/utils/PageData.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/utils/ApiResult.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/utils/Tools.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/service/UsersService.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/config/RedisConfig.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/service/impl/UsersServiceImpl.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/AlexApiApplication.java +/home/alex/alex-api/src/main/java/com/ctgu/alexapi/controller/UsersController.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..a04bc70 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1 @@ +com/ctgu/alexapi/AlexApiApplicationTests.class diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..ae1abf0 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1 @@ +/home/alex/alex-api/src/test/java/com/ctgu/alexapi/AlexApiApplicationTests.java diff --git a/target/test-classes/com/ctgu/alexapi/AlexApiApplicationTests.class b/target/test-classes/com/ctgu/alexapi/AlexApiApplicationTests.class new file mode 100644 index 0000000..42acd4e Binary files /dev/null and b/target/test-classes/com/ctgu/alexapi/AlexApiApplicationTests.class differ