From 26381dd7a78e9f799b348108f62b3c8733617701 Mon Sep 17 00:00:00 2001 From: muxinyun <9340971+muxinyun@user.noreply.gitee.com> Date: Tue, 28 Mar 2023 01:46:51 +0000 Subject: [PATCH 1/4] comment Dockerfile --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..defaf1d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM maven:3-jdk-8-alpine + +# 设置工作区 +WORKDIR /usr/src/app + +# 拷贝代码并执行maven构建 +COPY . /usr/src/app +RUN mvn package + +# 设置环境变量与运行命令 +ENV PORT 5000 +EXPOSE $PORT +CMD [ "sh", "-c", "mvn -Dserver.port=${PORT} spring-boot:run" ] -- Gitee From 684f965f305d14fd778b5dd20d85ead9f3706f1d Mon Sep 17 00:00:00 2001 From: muxinyun <9340971+muxinyun@user.noreply.gitee.com> Date: Tue, 28 Mar 2023 03:08:48 +0000 Subject: [PATCH 2/4] add default pipeline template yaml --- .workflow/branch-pipeline.yml | 58 +++++++++++++++++++++++++++++++++++ .workflow/master-pipeline.yml | 56 +++++++++++++++++++++++++++++++++ .workflow/pr-pipeline.yml | 43 ++++++++++++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 .workflow/branch-pipeline.yml create mode 100644 .workflow/master-pipeline.yml create mode 100644 .workflow/pr-pipeline.yml diff --git a/.workflow/branch-pipeline.yml b/.workflow/branch-pipeline.yml new file mode 100644 index 0000000..4eae085 --- /dev/null +++ b/.workflow/branch-pipeline.yml @@ -0,0 +1,58 @@ +version: '1.0' +name: branch-pipeline +displayName: BranchPipeline +stages: + - stage: + name: compile + displayName: 编译 + steps: + - step: build@golang + name: build_golang + displayName: Golang 构建 + # 支持1.8、1.10、1.11、1.12、1.13、1.14、1.15、1.16八个版本 + golangVersion: 1.12 + # 构建命令 + commands: | + mkdir output + GOOS=linux GOARCH=amd64 go build -o output/main.amd64 main.go + GOOS=linux GOARCH=386 go build -o output/main.linux32 main.go + GOOS=windows GOARCH=amd64 go build -o output/main.win64.exe main.go + GOOS=windows GOARCH=386 go build -o output/main.win32.exe main.go + GOOS=darwin GOARCH=amd64 go build -o output/main.darwin main.go + chmod +X output/main.linux32 + ./output/main.linux32 + # 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除 + artifacts: + # 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址 + - name: BUILD_ARTIFACT + # 构建产物获取路径,是指代码编译完毕之后构建物的所在路径 + path: + - ./output + - step: publish@general_artifacts + name: publish_general_artifacts + displayName: 上传制品 + # 上游构建任务定义的产物名,默认BUILD_ARTIFACT + dependArtifact: BUILD_ARTIFACT + # 上传到制品库时的制品命名,默认output + artifactName: output + dependsOn: build_golang + - stage: + name: release + displayName: 发布 + steps: + - step: publish@release_artifacts + name: publish_release_artifacts + displayName: '发布' + # 上游上传制品任务的产出 + dependArtifact: output + # 发布制品版本号 + version: '1.0.0.0' + # 是否开启版本号自增,默认开启 + autoIncrement: true +triggers: + push: + branches: + exclude: + - master + include: + - .* diff --git a/.workflow/master-pipeline.yml b/.workflow/master-pipeline.yml new file mode 100644 index 0000000..8e98549 --- /dev/null +++ b/.workflow/master-pipeline.yml @@ -0,0 +1,56 @@ +version: '1.0' +name: master-pipeline +displayName: MasterPipeline +stages: + - stage: + name: compile + displayName: 编译 + steps: + - step: build@golang + name: build_golang + displayName: Golang 构建 + # 支持1.8、1.10、1.11、1.12、1.13、1.14、1.15、1.16八个版本 + golangVersion: 1.12 + # 构建命令 + commands: | + mkdir output + GOOS=linux GOARCH=amd64 go build -o output/main.amd64 main.go + GOOS=linux GOARCH=386 go build -o output/main.linux32 main.go + GOOS=windows GOARCH=amd64 go build -o output/main.win64.exe main.go + GOOS=windows GOARCH=386 go build -o output/main.win32.exe main.go + GOOS=darwin GOARCH=amd64 go build -o output/main.darwin main.go + chmod +X output/main.linux32 + ./output/main.linux32 + # 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,24小时后自动清除 + artifacts: + # 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址 + - name: BUILD_ARTIFACT + # 构建产物获取路径,是指代码编译完毕之后构建物的所在路径 + path: + - ./output + - step: publish@general_artifacts + name: publish_general_artifacts + displayName: 上传制品 + # 上游构建任务定义的产物名,默认BUILD_ARTIFACT + dependArtifact: BUILD_ARTIFACT + # 上传到制品库时的制品命名,默认output + artifactName: output + dependsOn: build_golang + - stage: + name: release + displayName: 发布 + steps: + - step: publish@release_artifacts + name: publish_release_artifacts + displayName: '发布' + # 上游上传制品任务的产出 + dependArtifact: output + # 发布制品版本号 + version: '1.0.0.0' + # 是否开启版本号自增,默认开启 + autoIncrement: true +triggers: + push: + branches: + include: + - master diff --git a/.workflow/pr-pipeline.yml b/.workflow/pr-pipeline.yml new file mode 100644 index 0000000..d1c02dc --- /dev/null +++ b/.workflow/pr-pipeline.yml @@ -0,0 +1,43 @@ +version: '1.0' +name: pr-pipeline +displayName: PRPipeline +stages: + - stage: + name: compile + displayName: 编译 + steps: + - step: build@golang + name: build_golang + displayName: Golang 构建 + # 支持1.8、1.10、1.11、1.12、1.13、1.14、1.15、1.16八个版本 + golangVersion: 1.12 + # 构建命令 + commands: | + mkdir output + GOOS=linux GOARCH=amd64 go build -o output/main.amd64 main.go + GOOS=linux GOARCH=386 go build -o output/main.linux32 main.go + GOOS=windows GOARCH=amd64 go build -o output/main.win64.exe main.go + GOOS=windows GOARCH=386 go build -o output/main.win32.exe main.go + GOOS=darwin GOARCH=amd64 go build -o output/main.darwin main.go + chmod +X output/main.linux32 + ./output/main.linux32 + # 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除 + artifacts: + # 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址 + - name: BUILD_ARTIFACT + # 构建产物获取路径,是指代码编译完毕之后构建物的所在路径 + path: + - ./output + - step: publish@general_artifacts + name: publish_general_artifacts + displayName: 上传制品 + # 上游构建任务定义的产物名,默认BUILD_ARTIFACT + dependArtifact: BUILD_ARTIFACT + # 上传到制品库时的制品命名,默认output + artifactName: output + dependsOn: build_golang +triggers: + pr: + branches: + include: + - master -- Gitee From 50f740231602b6adfd7cc8c8fd471df21eb43027 Mon Sep 17 00:00:00 2001 From: muxinyun <9340971+muxinyun@user.noreply.gitee.com> Date: Wed, 29 Mar 2023 06:03:13 +0000 Subject: [PATCH 3/4] update branch-pipeline.yml --- .workflow/branch-pipeline.yml | 82 +++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/.workflow/branch-pipeline.yml b/.workflow/branch-pipeline.yml index 4eae085..8fc2f88 100644 --- a/.workflow/branch-pipeline.yml +++ b/.workflow/branch-pipeline.yml @@ -1,58 +1,64 @@ version: '1.0' name: branch-pipeline displayName: BranchPipeline +triggers: + trigger: auto + push: + branches: + include: + - .* + exclude: + - master stages: - - stage: - name: compile + - name: compile displayName: 编译 + strategy: naturally + trigger: auto steps: - - step: build@golang - name: build_golang - displayName: Golang 构建 - # 支持1.8、1.10、1.11、1.12、1.13、1.14、1.15、1.16八个版本 - golangVersion: 1.12 - # 构建命令 - commands: | - mkdir output - GOOS=linux GOARCH=amd64 go build -o output/main.amd64 main.go - GOOS=linux GOARCH=386 go build -o output/main.linux32 main.go - GOOS=windows GOARCH=amd64 go build -o output/main.win64.exe main.go - GOOS=windows GOARCH=386 go build -o output/main.win32.exe main.go - GOOS=darwin GOARCH=amd64 go build -o output/main.darwin main.go - chmod +X output/main.linux32 - ./output/main.linux32 - # 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除 + - step: build@maven + name: build_maven + displayName: Maven 构建 + jdkVersion: '8' + mavenVersion: 3.3.9 + commands: + - '# 功能:打包' + - '# 参数说明:' + - '# -Dmaven.test.skip=true:跳过单元测试' + - '# -U:每次构建检查依赖更新,可避免缓存中快照版本依赖不更新问题,但会牺牲部分性能' + - '# -e -X :打印调试信息,定位疑难构建问题时建议使用此参数构建' + - '# -B:以batch模式运行,可避免日志打印时出现ArrayIndexOutOfBoundsException异常' + - '# 使用场景:打包项目且不需要执行单元测试时使用' + - mvn clean package -Dmaven.test.skip=true -U -e -X -B + - '' + - '# 功能:自定义settings配置' + - '# 使用场景:如需手工指定settings.xml,可使用如下方式' + - '# 注意事项:如无需自定义settings配置且需要私有依赖仓库,可在该任务配置《私有仓库》处添加私有依赖' + - '# mvn -U clean package -s ./settings.xml' + - '' artifacts: - # 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址 - name: BUILD_ARTIFACT - # 构建产物获取路径,是指代码编译完毕之后构建物的所在路径 path: - - ./output + - ./target + settings: [] + caches: + - ~/.m2 + notify: [] + strategy: + retry: '0' - step: publish@general_artifacts name: publish_general_artifacts displayName: 上传制品 - # 上游构建任务定义的产物名,默认BUILD_ARTIFACT dependArtifact: BUILD_ARTIFACT - # 上传到制品库时的制品命名,默认output artifactName: output - dependsOn: build_golang - - stage: - name: release + dependsOn: build_maven + - name: release displayName: 发布 + strategy: naturally + trigger: auto steps: - step: publish@release_artifacts name: publish_release_artifacts - displayName: '发布' - # 上游上传制品任务的产出 + displayName: 发布 dependArtifact: output - # 发布制品版本号 - version: '1.0.0.0' - # 是否开启版本号自增,默认开启 + version: 1.0.0.0 autoIncrement: true -triggers: - push: - branches: - exclude: - - master - include: - - .* -- Gitee From f62f2577851dffe36c09cdb1ad1aeebe91622056 Mon Sep 17 00:00:00 2001 From: muxinyun <9340971+muxinyun@user.noreply.gitee.com> Date: Wed, 29 Mar 2023 08:08:33 +0000 Subject: [PATCH 4/4] add test01 --- test01 | 1 + 1 file changed, 1 insertion(+) create mode 100644 test01 diff --git a/test01 b/test01 new file mode 100644 index 0000000..c46d0ae --- /dev/null +++ b/test01 @@ -0,0 +1 @@ +test01 \ No newline at end of file -- Gitee