From f75b86833ab64a23e7a770b3c175804cfc3e429a Mon Sep 17 00:00:00 2001 From: moshenglv Date: Mon, 4 Jan 2021 15:10:53 +0800 Subject: [PATCH] test --- .drone.yml | 24 +++++++++++++++ .trustie-pipeline.yml | 31 +++++++++++++------- Dockerfile | 10 +++++++ README.md | 21 ++------------ deploy.sh | 6 ++++ pom.xml | 37 ++++++++++++++++++++++++ src/main/java/Test.java | 7 +++++ src/main/java/Test1.java | 7 +++++ src/main/java/controller/HelloWorld.java | 35 ++++++++++++++++++++++ src/main/webapp/WEB-INF/web.xml | 15 ++++++++++ 10 files changed, 164 insertions(+), 29 deletions(-) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 deploy.sh create mode 100644 pom.xml create mode 100644 src/main/java/Test.java create mode 100644 src/main/java/Test1.java create mode 100644 src/main/java/controller/HelloWorld.java create mode 100644 src/main/webapp/WEB-INF/web.xml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..1e04415 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,24 @@ +kind: pipeline +name: maven项目-镜像仓库 + +steps: +- name: Maven编译 + image: maven:3-jdk-10 + commands: + - mvn install + +- name: 执行-部署脚本 + image: docker:dind + volumes: + - name: dockersock + path: /var/run/docker.sock + commands: + - docker ps + - chmod +x ./deploy.sh + - ./deploy.sh + + +volumes: +- name: dockersock + host: + path: /var/run/docker.sock \ No newline at end of file diff --git a/.trustie-pipeline.yml b/.trustie-pipeline.yml index be1761f..1e04415 100644 --- a/.trustie-pipeline.yml +++ b/.trustie-pipeline.yml @@ -1,13 +1,24 @@ kind: pipeline - name: default +name: maven项目-镜像仓库 - platform: - os: linux - arch: arm64 +steps: +- name: Maven编译 + image: maven:3-jdk-10 + commands: + - mvn install - steps: - - name: test - image: maven:3-jdk-10 - commands: - - mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V - - mvn test -B \ No newline at end of file +- name: 执行-部署脚本 + image: docker:dind + volumes: + - name: dockersock + path: /var/run/docker.sock + commands: + - docker ps + - chmod +x ./deploy.sh + - ./deploy.sh + + +volumes: +- name: dockersock + host: + path: /var/run/docker.sock \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2ce5497 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ + +#添加docker镜像 +FROM tomcat + +#添加作者信息 +MAINTAINER moshenglv@163.com + +#复制应用程序 +COPY target/demo-1.war /usr/local/tomcat/webapps/demo.war + diff --git a/README.md b/README.md index 3dfc05c..16273cf 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,3 @@ -#### 从命令行创建一个新的仓库 - -```bash -touch README.md -git init -git add README.md -git commit -m "first commit" -git remote add origin http://testgitea2.trustie.net/cxt/devops-test.git -git push -u origin master - -``` - -#### 从命令行推送已经创建的仓库 - -```bash -git remote add origin http://testgitea2.trustie.net/cxt/devops-test.git -git push -u origin master - -``` +# MyTest +test \ No newline at end of file diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..b3aa4d8 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,6 @@ +echo ====暂停容器开始======= +docker rm -f devops-test +echo ====开始部署======= +docker build -t devops-test:1.0 . +docker run -d -p 8080:8080 --name devops-test devops-test:1.0 +echo ====部署成功====== \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..abb6bac --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + com.example + demo + 1 + demo + war + + + 1.8 + 1.8 + 5.6.2 + + + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.3.0 + + + + \ No newline at end of file diff --git a/src/main/java/Test.java b/src/main/java/Test.java new file mode 100644 index 0000000..8146d29 --- /dev/null +++ b/src/main/java/Test.java @@ -0,0 +1,7 @@ +public class Test { + + //测试111112 + public static void main(String[] args){ + + } +} diff --git a/src/main/java/Test1.java b/src/main/java/Test1.java new file mode 100644 index 0000000..8146d29 --- /dev/null +++ b/src/main/java/Test1.java @@ -0,0 +1,7 @@ +public class Test { + + //测试111112 + public static void main(String[] args){ + + } +} diff --git a/src/main/java/controller/HelloWorld.java b/src/main/java/controller/HelloWorld.java new file mode 100644 index 0000000..8f65637 --- /dev/null +++ b/src/main/java/controller/HelloWorld.java @@ -0,0 +1,35 @@ +package controller; + +import javax.servlet.ServletException; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +public class HelloWorld extends HttpServlet { + + private String message; + + @Override + public void init() throws ServletException { + message = "Hello world, this message is from servlet!"; + } + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + //设置响应内容类型 + resp.setContentType("text/html"); + + //设置逻辑实现 + PrintWriter out = resp.getWriter(); + out.println("

" + message + "

"); + } + + @Override + public void destroy() { + super.destroy(); + } + +} diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..c67f0d9 --- /dev/null +++ b/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,15 @@ + + + + + HelloWorld + controller.HelloWorld + + + HelloWorld + /hello + + \ No newline at end of file