diff --git a/.workflow/.keep b/.workflow/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.workflow/artifact-repo-test.yml b/.workflow/artifact-repo-test.yml new file mode 100644 index 0000000000000000000000000000000000000000..b75449dd9557504ab8c013d36c349312752eb0e8 --- /dev/null +++ b/.workflow/artifact-repo-test.yml @@ -0,0 +1,49 @@ +version: '1.0' +name: artifact-repo-test +displayName: 测试整体流程 +triggers: + trigger: auto + push: + branches: + prefix: + - '' +stages: + - name: stage-eb6f4330111 + displayName: 编译上传 + strategy: naturally + trigger: auto + executor: [] + steps: + - step: build@maven + name: build_maven + displayName: Maven 构建 + jdkVersion: '8' + mavenVersion: 3.3.9 + commands: + - mvn -B clean package -Dmaven.test.skip=true + artifacts: + - name: BUILD_ARTIFACT + path: + - ./target + settings: [] + - step: publish@general_artifacts + name: publish_general_artifacts + displayName: 上传制品 + dependArtifact: BUILD_ARTIFACT + artifactName: output + dependsOn: build_maven + - name: stage-2ced98371 + displayName: 发布 + strategy: naturally + trigger: auto + executor: [] + steps: + - step: publish@release_artifacts + name: publish_release_artifacts + displayName: 发布 + dependArtifact: output + version: 1.0.0.0 + autoIncrement: true +permissions: + - role: admin + members: [] diff --git a/.workflow/deploy.yml b/.workflow/deploy.yml deleted file mode 100644 index 9011532994408d6056d31ca7d4eeea611a6bc9c0..0000000000000000000000000000000000000000 --- a/.workflow/deploy.yml +++ /dev/null @@ -1,56 +0,0 @@ -# ======================================================== -# 基于 Maven 构建部署 SpringBoot 流水线示例 -# 功能:通过 Maven 编译构建 SpringBoot 项目并部署到主机 -# ======================================================== -name: spring-boot-maven-ci # 定义一个唯一 ID 标识为 spring-boot-maven-ci ,名称为「Spring Boot(Maven)示例」的流水线 -displayName: 'Spring Boot(Maven)示例' -triggers: # 流水线触发器配置 - push: # 设置 master 分支 在产生代码 push 时精确触发(PRECISE)构建 - - matchType: PRECISE - branch: master -commitMessage: '' # 通过匹配当前提交的 CommitMessage 决定是否执行流水线 -stages: # 构建阶段配置 - - stage: # 定义一个 ID 标识为 spring-boot-build-stage ,名为「Build Stage」的阶段 - name: spring-boot-stage - displayName: 'Spring Boot Stage' - failFast: false # 允许快速失败,即当 Stage 中有任务失败时,直接结束整个 Stage - steps: # 构建步骤配置 - - step: mavenbuild@1 # 采用 Maven 编译环境 - name: spring-boot-build-step # 定义一个 ID 标识为 spring-boot-build-step ,名为「编译构建」的阶段 - displayName: '编译构建' - inputs: # 构建输入参数设定 - jdkVersion: 8 # 指定 JDK 环境版本为 1.8 - mavenVersion: 3.6 # 指定 Maven 环境版本为 3.6 - goals: | # 使用 mvnw 打包编译,并将构建的 Jar 包 - mvn clean package - mkdir output-artifact - cp target/maven-demo-0.0.1-SNAPSHOT.jar output-artifact/ - uploadArtifact: true # 构建完成后是否将构建物作为制品产出,非必填项,与下方上传参数需同时定义 - uploadArtifactOptions: # 构建物上传参数,非必填项,与 `uploadArtifact` 参数需同时定义 - artifactPath: './output-artifact' # 构建完成后要打包的构建物所在路径 - artifactRepository: 'default' # 制品库名称,可以理解为一批构建物的集合 - artifactName: 'spring-boot-jar' # 构建物打包后的制品名 - - step: agent-deploy@1 # 定义通过 SA 部署插件 - name: deploy # Step 唯一标识 - dependsOn: spring-boot-build-step - displayName: '部署发布' # Step 显示名称 - inputs: # Step 入参 - hostGroupID: 'backend' # 指定部署主机组ID - minComplicating: 0 # 允许的最小并发部署数量 - maxComplicating: 2 # 允许的最大并发部署数量 - deployArtifact: # 上传的制品项 - - name: 'compiled-artifact' # 上传部署的制品名(仅作为显示,无具体作用,允许重复) - source: build@spring-boot-stage/spring-boot-build-step # 部署制品文件引用自上游流水线 Stage/Step 的制品 - artifactRepository: 'compiled-artifact' # 当制品引用自流水线,此参数可忽略 - artifactName: 'server' # 当制品引用自流水线,此参数可忽略 - target: /data # 目标机器制品上传目录 - isForce: true # 当目标存在时是否强制覆盖,默认为 true,可选 - script: | # 部署脚本,到目标机器制品上传目录解压并启动构建程序,并通过curl检测 - cd /data - ls - tar -zxf spring-boot-jar.tar.gz - cd output-artifact - nohup java -jar maven-demo-0.0.1-SNAPSHOT.jar & - echo "Deploy Success" - sleep 10 - curl 127.0.0.1:8080 diff --git a/.workflow/jenkins-test.yml b/.workflow/jenkins-test.yml new file mode 100644 index 0000000000000000000000000000000000000000..5894ba051e6323ccb6c279c28880506872cca2d9 --- /dev/null +++ b/.workflow/jenkins-test.yml @@ -0,0 +1,24 @@ +version: '1.0' +name: jenkins-test +displayName: jenkins-test +triggers: + trigger: auto + push: + branches: + prefix: + - '' +stages: + - name: stage-2b2e07601 + displayName: Jenkins阶段 + strategy: naturally + trigger: auto + executor: [] + steps: + - step: build@jenkins + name: build_jenkins + displayName: Jenkins Job + certificate: jenkins-test + job: 徐旭测试(Maven项目) +permissions: + - role: admin + members: [] diff --git a/.workflow/master-pipeline.yml b/.workflow/master-pipeline.yml new file mode 100644 index 0000000000000000000000000000000000000000..e8fd1c1ed5092ab63b953252ff18bf7fcf530a4e --- /dev/null +++ b/.workflow/master-pipeline.yml @@ -0,0 +1,73 @@ +version: '1.0' +name: master-pipeline +displayName: MasterPipeline +triggers: + trigger: auto + push: + branches: + include: + - master +stages: + - name: compile + displayName: 编译1 + strategy: naturally + trigger: auto + steps: + - step: build@maven + name: build_maven + displayName: Maven 构建 + jdkVersion: 8 + mavenVersion: 3.3.9 + artifacts: + - name: BUILD_ARTIFACT + path: + - ./target + commands: + - mvn -B clean test package -Dmaven.test.failure.ignore=true + - step: publish@general_artifacts + name: publish_general_artifacts + displayName: 上传制品 + dependArtifact: BUILD_ARTIFACT + artifactRepository: default + artifactName: output + dependsOn: build_maven + - name: release + displayName: 发布 + strategy: naturally + trigger: auto + steps: + - step: publish@release_artifacts + name: publish_release_artifacts + displayName: 发布 + dependArtifact: output + artifactRepository: release + version: 1.0.0.0 + autoIncrement: true + - name: deploy + displayName: 部署 + strategy: naturally + trigger: manual + steps: + - step: deploy@agent + name: deploy_agent + displayName: 主机部署 + hostGroupID: gitee-go-test + deployArtifact: + - source: artifact + name: output + target: ~/gitee_go/deoloy + artifactRepository: release + artifactName: output + artifactVersion: latest + script: | + cd ~/gitee_go/deoloy + ls + tar -zxf output.tar.gz + cd target + nohup java -jar maven-demo-0.0.1-SNAPSHOT.jar --server.port=7081 & + echo "Deploy Success" + sleep 10 + curl 127.0.0.1:7081 +permissions: + - role: admin + members: [] diff --git a/.workflow/old-pipe-test.yml b/.workflow/old-pipe-test.yml new file mode 100644 index 0000000000000000000000000000000000000000..e39c4ff0394fc4a6404893b29ee18a5330e8a7c8 --- /dev/null +++ b/.workflow/old-pipe-test.yml @@ -0,0 +1,21 @@ +name: old-pipe-test +displayName: '旧Yaml测试' +triggers: # 流水线触发器配置 + push: # 设置 master 分支 在产生代码 push 时精确触发(PRECISE)构建 + - matchType: PRECISE + branch: master +commitMessage: '' # 通过匹配当前提交的 C1ommitMessage 决定是否执行流水线 +stages: # 构建阶段配置 + - stage: # 定义一个 ID 标识为 npm-build-stage ,名为 “npm Stage” 的阶段 + name: build-stage + displayName: 'Maven Stage' + failFast: false # 允许快速失败,即当 Stage 中有任务失败时,直接结束整个 Stage + steps: # 构建步骤配置 + - step: mavenbuild@1 # 构建步骤的任务类型(枚举类型),用于决定使用什么构建环境。目前不支持自定义。当前示例为采用 Maven 编译环境 + name: maven-build # 构建步骤唯一标识,当前示例中定义了一个标识为 maven-build 的构建步骤 + displayName: 'Maven Step' # 构建步骤名称当前示例中定义了一个名为 “Maven Step” 的构建步骤 + inputs: # 构建输入参数设定 + jdkVersion: 8 # 语言版本,指定 JDK 环境版本为 1.8 + mavenVersion: 3.6 # 工具版本,指定 Maven 环境版本为 3.6 + goals: | # 构建脚本,当前示例中使用 Maven 命令初始化、构建一个 Maven 工程并执行输出内容 + mvn -v \ No newline at end of file diff --git a/.workflow/test-maven.yml b/.workflow/test-maven.yml new file mode 100644 index 0000000000000000000000000000000000000000..402195fc7db1ebbb9a40eda31fea9c9e9ded53e7 --- /dev/null +++ b/.workflow/test-maven.yml @@ -0,0 +1,52 @@ +version: '1.0' +name: pipeline-20220218-1 +displayName: pipeline-20220218-1 +triggers: + trigger: auto + push: + branches: + prefix: + - '' +stages: + - name: stage-9a113c4b1 + displayName: 编译 + strategy: naturally + trigger: auto + executor: [] + steps: + - step: build@maven + name: build_maven + displayName: Maven 构建 + jdkVersion: '11' + mavenVersion: 3.3.9 + commands: + - java -version + - ls + - pwd + - mvn -B clean package -Dmaven.test.skip=true + artifacts: + - name: BUILD_ARTIFACT + path: + - ./target + settings: [] + - step: publish@general_artifacts + name: publish_general_artifacts + displayName: 上传制品 + dependArtifact: BUILD_ARTIFACT + artifactName: output + dependsOn: build_maven + - name: stage-c3279b5f + displayName: 发布 + strategy: naturally + trigger: auto + executor: [] + steps: + - step: publish@release_artifacts + name: publish_release_artifacts + displayName: 发布 + dependArtifact: output + version: 1.0.0.0 + autoIncrement: true +permissions: + - role: admin + members: [] diff --git a/.workflow/test.yml b/.workflow/test.yml new file mode 100644 index 0000000000000000000000000000000000000000..80afc63e84a2ea731ab0cf7677c1309d22b863ee --- /dev/null +++ b/.workflow/test.yml @@ -0,0 +1,19 @@ +version: '1.0' +name: pipeline-20211028 +displayName: pipeline-20211028 +stages: + - stage: '' + name: stage_name_56 + displayName: stage_display_name_571 + steps: + - step: build@nodejs + name: build_nodejs_63 + displayName: Nodejs 构建 + nodeVersion: 12.16.1 + commands: + - ls +triggers: + push: + branches: + include: + - master \ No newline at end of file diff --git a/.workflow/xx.yml b/.workflow/xx.yml new file mode 100644 index 0000000000000000000000000000000000000000..4093b4a7a41991700e8ebaf39044c353cf5cda2f --- /dev/null +++ b/.workflow/xx.yml @@ -0,0 +1,55 @@ +version: '1.0' +name: xx-master-pipeline +displayName: xx-MasterPipeline +stages: + - stage: + name: compile + displayName: 编译 + steps: + - step: build@maven + name: build_maven + displayName: Maven 构建 + # 支持6、7、8、9、10、11六个版本 + jdkVersion: 8 + # 支持2.2.1、3.2.5、3.3.9、3.5.2、3.5.3、3.5.4、3.6.1、3.6.3八个版本 + mavenVersion: 3.3.9 + # 构建命令 + commands: + - mvn -B clean package -Dmaven.test.skip=true + # 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除 + artifacts: + # 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址 + - name: BUILD_ARTIFACT + # 构建产物获取路径,是指代码编译完毕之后构建物的所在路径,如通常jar包在target目录下。当前目录为代码库根目录 + path: + - ./target + - step: publish@general_artifacts + name: publish_general_artifacts + displayName: 上传制品 + # 上游构建任务定义的产物名,默认BUILD_ARTIFACT + dependArtifact: BUILD_ARTIFACT + # 构建产物制品库,默认default,系统默认创建 + artifactRepository: default + # 上传到制品库时的制品命名,默认build + artifactName: output + dependsOn: build_maven + - stage: + name: release + displayName: 发布 + steps: + - step: publish@release_artifacts + name: publish_release_artifacts + displayName: '发布' + # 上游上传制品任务的产出 + dependArtifact: output + # 发行版制品库,默认release,系统默认创建 + artifactRepository: release + # 发布制品版本号 + version: '1.0.0.0' + # 是否开启版本号自增,默认开启 + autoIncrement: true +triggers: + push: + branches: + include: + - master diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f9c0b6ebdbff3c262b7ebc2cbd6b67ad9540529c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM alpine:latest +RUN set -eux && sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories +RUN apk add busybox-extras curl +CMD ["echo","Hello DevOps"] \ No newline at end of file diff --git a/HELP.md b/HELP.md index e7fd88cdc2d1d1eb31016357396d1f7fe0eff3e1..3ba3603cc08cf7d1bea05cb11396ba3dc457639a 100644 --- a/HELP.md +++ b/HELP.md @@ -1,9 +1,8 @@ -# Getting Started -### Reference Documentation -For further reference, please consider the following sections: +### Reference Documentation1 +For further reference, please cffffonsider the following sections: -* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Official Apache Maven doqweqwcumentation](https://maven.apache.org/guides/index.html) * [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.4.0/maven-plugin/reference/html/) * [Create an OCI image](https://docs.spring.io/spring-boot/docs/2.4.0/maven-plugin/reference/html/#build-image) * [Spring Web](https://docs.spring.io/spring-boot/docs/2.4.0/reference/htmlsingle/#boot-features-developing-web-applications) diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..38875364646809a31f1121a08e980aaba22d3c13 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,32 @@ +pipeline { + agent { + node { + label "agent-119" + } + } + + stages { + stage('Build') { + steps { + sh ''' + ls + sleep 20 + ''' + } + } + stage('BuildImage') { + steps { + sh ''' + ls + ''' + } + } + stage('Deploy') { + steps { + sh ''' + ls + ''' + } + } + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 12306761872652018293c050373ecffb6b1fc89e..d10873d59be38ec3bce8302f74cf4108d6a42b15 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,45 @@ org.springframework.boot spring-boot-maven-plugin + + org.jacoco + jacoco-maven-plugin + 0.7.9 + + + pre-unit-test + + prepare-agent + + + surefireArgLine + + + + post-unit-test + test + + report + + + ${basedir}/target/jacoco.exec + ${basedir}/target/site/jacoco + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + ${surefireArgLine} + false + + **/*Test*.java + + + diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000000000000000000000000000000000..6e4da25152efc7c371f8631b671d2581a5e4b82f --- /dev/null +++ b/test.txt @@ -0,0 +1,3 @@ +wwwww + +111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111