nacos-sentinel/.gitlab-ci.yml

97 lines
2.8 KiB
YAML

stages:
- build:java
- build:docker
- sync
build:java:
stage: build:java
image: maven:3.6.3-jdk-8
variables:
MAVEN_OPTS: >-
-Dhttps.protocols=TLSv1.2
-Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository
-Dorg.slf4j.simpleLogger.showDateTime=true
-Djava.awt.headless=true
MAVEN_CLI_OPTS: >-
--batch-mode
--errors
--fail-at-end
--show-version
--no-transfer-progress
-DinstallAtEnd=true
-DdeployAtEnd=true
script:
#- SETTINGS_FILE=`find / -name settings.xml`
#- echo $SETTINGS_FILE
- SETTINGS_FILE=/usr/share/maven/conf/settings.xml
- GROUP_ID=`mvn -e help:evaluate -Dexpression=project.groupId -q -DforceStdout`
- ARTIFACT_ID=`mvn -e help:evaluate -Dexpression=project.artifactId -q -DforceStdout`
- VERSION=`mvn -e help:evaluate -Dexpression=project.version -q -DforceStdout`
- echo "GROUP_ID=$GROUP_ID" >> env.txt
- echo "ARTIFACT_ID=$ARTIFACT_ID" >> env.txt
- echo "VERSION=$VERSION" >> env.txt
- cat env.txt
- sed -i "s#</servers>#<server><id>ossrh</id><username>$ossrh_user</username><password>$ossrh_pass</password></server>&#" $SETTINGS_FILE
- mvn clean package source:jar javadoc:jar deploy -DskipTests=true
artifacts:
name: nacos-sentinel
paths:
- target/*.jar
reports:
dotenv:
- env.txt
cache:
key: "${CI_JOB_NAME}"
paths:
- .m2/repository
rules:
- changes:
- src/**/**
- .gitlab-ci.yml
- .springjavaformatconfig
- Dockerfile
- pom.xml
build:docker:
stage: build:docker
image:
name: gcr.io/kaniko-project/executor:v1.9.2-debug
entrypoint: [ "" ]
needs:
- job: build:java
artifacts: true
variables:
NACOS_SENTINEL_JAVA_OPTS: -Xms256m -Xmx512m
before_script:
- echo "{\"auths\":{\"https://index.docker.io/v1/\":{\"auth\":\"$(printf "%s:%s" "${DOCKER_USERNAME}" "${DOCKER_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- echo $GROUP_ID
- echo $ARTIFACT_ID
- echo $VERSION
- /kaniko/executor version
- /kaniko/executor --help
- >-
/kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/Dockerfile"
--build-arg CI_SERVER_URL=${CI_SERVER_URL}
--build-arg CI_PIPELINE_ID=${CI_PIPELINE_ID}
--build-arg CI_JOB_ID=${CI_JOB_ID}
--build-arg NACOS_SENTINEL_JAVA_OPTS="${NACOS_SENTINEL_JAVA_OPTS}"
--build-arg GROUP_ID=${GROUP_ID}
--build-arg ARTIFACT_ID=${ARTIFACT_ID}
--build-arg VERSION=${VERSION}
--destination "${DOCKER_USERNAME}/${ARTIFACT_ID}:${VERSION}-${CI_PIPELINE_ID}"
rules:
- changes:
- src/**/**
- .gitlab-ci.yml
- .springjavaformatconfig
- Dockerfile
- pom.xml
# 嵌入
include:
# 同步代码
- /sync.yml