代码拉取完成,页面将自动刷新
before_script:
- rm -rf /root/.m2/settings.xml
- echo -e "<?xml version=\""1.0\"" encoding=\""UTF-8\""?><settings xmlns=\""http://maven.apache.org/SETTINGS/1.0.0\"" xmlns:xsi=\""http://www.w3.org/2001/XMLSchema-instance\"" xsi:schemaLocation=\""http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd\""><mirrors><mirror><id>mirror</id><name>mirror</name><url>https://maven.aliyun.com/nexus/content/groups/public</url><mirrorOf>central,jcenter,!rdc-releases,!rdc-snapshots</mirrorOf></mirror> </mirrors> <servers>
<server>
<id>rdc-releases</id>
<username>617d503fbc6f250a94c5d6ec</username>
<password>VDzlsL5jYZot</password>
</server>
<server>
<id>rdc-snapshots</id>
<username>617d503fbc6f250a94c5d6ec</username>
<password>VDzlsL5jYZot</password>
</server>
</servers>
<profiles>
<profile>
<id>rdc</id>
<properties>
<altReleaseDeploymentRepository>
rdc-releases::default::https://packages.aliyun.com/maven/repository/2150952-release-4Nd0Uf/
</altReleaseDeploymentRepository>
<altSnapshotDeploymentRepository>
rdc-snapshots::default::https://packages.aliyun.com/maven/repository/2150952-snapshot-LmgYUo/
</altSnapshotDeploymentRepository>
</properties>
<repositories>
<repository>
<id>central</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>rdc-releases</id>
<url>https://packages.aliyun.com/maven/repository/2150952-release-4Nd0Uf/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>rdc-snapshots</id>
<url>https://packages.aliyun.com/maven/repository/2150952-snapshot-LmgYUo/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>https://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>rdc-releases</id>
<url>https://packages.aliyun.com/maven/repository/2150952-release-4Nd0Uf/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>rdc-snapshots</id>
<url>https://packages.aliyun.com/maven/repository/2150952-snapshot-LmgYUo/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>rdc</activeProfile>
</activeProfiles>
</settings>" > /root/.m2/settings.xml
# 定义一些变量, 下面各阶段会使用
variables:
jar_name: service-1.0-SNAPSHOT.jar
java_path: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64/bin
TAG: login-service:v1.0 # 镜像名称
CONTAINER_NAME: login-service-provider
PORT: 8011
DOCKER_DRIVER: overlay2
# 定义执行的各个阶段及顺序
stages:
- build
- deploy
# 使用 maven 镜像打包项目
maven-build:
stage: build
image: maven:3.5.0-jdk-8
script:
- mvn package -B -Dmaven.test.skip=true
cache:
key: m2-repo
paths:
- .m2/repository
artifacts:
paths:
- ./service/target/$jar_name
build-main: # 定义的 Jobs 之一,用于构建 Docker 镜像。负责执行 deploy 这一流程。具体执行 build 和 run。
stage: deploy
tags:
- backup deploy
script:
# - docker stop $CONTAINER_NAME
# - docker rmi -f $TAG
- docker build -t $TAG . # 构件镜像
- docker rm -f $CONTAINER_NAME || true # 删除容器
- docker run -d --name $CONTAINER_NAME -p $PORT:$PORT $TAG # 运行容器
only: # 指定哪些branch的push commit会触发执行该job,本例子指定只有master才会执行deploy这个job
- backup
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。