This is an automated email from the ASF dual-hosted git repository.

jinrongtong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/rocketmq-test-tool.git

commit 2d76e9513d9e0d735b718e41b615c498ea7f481c
Author: wangtong.wt <[email protected]>
AuthorDate: Wed Feb 22 16:23:03 2023 +0800

    Initialize test tool files
---
 Dockerfile                         |  24 +++
 README.md                          |  61 ++++++-
 action.yml                         |  94 +++++++++++
 entry.sh                           | 320 +++++++++++++++++++++++++++++++++++++
 test-runner/Dockerfile-test-runner |  34 ++++
 test-runner/code_run.sh            |  32 ++++
 test-runner/settings.xml           | 270 +++++++++++++++++++++++++++++++
 7 files changed, 834 insertions(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..f9ff8aa
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Container image that runs your code
+FROM cloudnativeofalibabacloud/test-runner:v0.0.1
+
+# Copies your code file from your action repository to the filesystem path `/` 
of the container
+COPY entry.sh /entry.sh
+
+# Code file to execute when the docker container starts up (`entry.sh`)
+ENTRYPOINT ["/entry.sh"]
\ No newline at end of file
diff --git a/README.md b/README.md
index 0de5b7c..6808016 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,60 @@
-## Apache RocketMQ Test Tool
+# cloud-native-test-ci-tool
+
+This action uses Helm and KubeVela to deploy applications and execute E2E 
tests in Kubernetes.
+KubeVela needs to be installed in Kubernetes before use.
+
+# Usage
+
+<!-- start usage -->
+## Use helm chart to deploy your app in Kubernetes
+```yaml
+  - uses: alibaba/cloud-native-test-ci-tool@v1
+    name: Deploy
+    with:
+      action: "deploy"
+      ask-config: "${{ secrets.KUBE_CONFIG }}"
+      test-version: "v1.0"
+      chart-git: "https://github.com/your-helm-chart.git";
+      chart-branch: "main"
+      chart-path: "."
+      job-id: 1
+      helm-values: |
+        app:
+          image:
+            repository: ${{env.DOCKER_REPO}}
+            tag: v1.0
+```
+## Execute your E2E test
+```yaml
+  - uses: alibaba/cloud-native-test-ci-tool@v1
+    name: e2e test
+    with:
+      action: "test"
+      ask-config: "${{ secrets.KUBE_CONFIG }}"
+      test-version: "v1.0"
+      test-code-git: "https://github.com/your-e2e-test.git";
+      test-code-branch: "main"
+      test-code-path: ./
+      test-cmd: "your test command"
+      job-id: 1
+  - uses: actions/upload-artifact@v3
+    if: always()
+    name: Upload test log
+    with:
+      name: testlog.txt
+      path: testlog.txt
+```
+## Clean your app in Kubernetes
+```yaml
+  - uses: alibaba/cloud-native-test-ci-tool@v1
+    name: clean
+    with:
+      action: "clean"
+      ask-config: "${{ secrets.KUBE_CONFIG }}"
+      test-version: "v1.0"
+      job-id: 1
+```
+<!-- end usage -->
+
+# License
+[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) 
Copyright (C) Apache Software Foundation
\ No newline at end of file
diff --git a/action.yml b/action.yml
new file mode 100644
index 0000000..56df133
--- /dev/null
+++ b/action.yml
@@ -0,0 +1,94 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# action.yml
+name: 'Cloud Native CI Action'
+description: ''
+inputs:
+  action: # id of input
+    description: 'action'
+    required: true
+    default: ''
+  test-version: # id of input
+    description: 'test version'
+    required: true
+    default: ''
+  ask-config:  # id of input
+    description: 'ask config'
+    required: true
+    default: ''
+  docker-repo-username: # id of input
+    description: 'docker repo username'
+    required: false
+    default: ''
+  docker-repo-password: # id of input
+    description: 'docker repo password'
+    required: false
+    default: ''
+  chart-git: # id of input
+    description: 'chart git'
+    required: false
+    default: ''
+  chart-branch: # id of input
+    description: 'chart branch'
+    required: false
+    default: ''
+  chart-path: # id of input
+    description: 'chart path'
+    required: false
+    default: './'
+  test-code-git: # id of input
+    description: 'test code git'
+    required: false
+    default: ''
+  test-code-branch: # id of input
+    description: 'test code branch'
+    required: false
+    default: ''
+  test-code-path: # id of input
+    description: 'test code path'
+    required: false
+    default: ''
+  test-cmd: # id of input
+    description: 'test cmd'
+    required: false
+    default: 'mvn -B test'
+  job-id: # id of input
+    description: 'job id'
+    required: true
+    default: ''
+  helm-values: # id of input
+    description: 'helm values'
+    required: true
+    default: ''
+runs:
+  using: 'docker'
+  image: 'Dockerfile'
+  args:
+    - ${{ inputs.action }}
+    - ${{ inputs.test-version }}
+    - ${{ inputs.ask-config }}
+    - ${{ inputs.docker-repo-username }}
+    - ${{ inputs.docker-repo-password }}
+    - ${{ inputs.chart-git }}
+    - ${{ inputs.chart-branch }}
+    - ${{ inputs.chart-path }}
+    - ${{ inputs.test-code-git }}
+    - ${{ inputs.test-code-branch }}
+    - ${{ inputs.test-code-path }}
+    - ${{ inputs.test-cmd }}
+    - ${{ inputs.job-id }}
+    - ${{ inputs.helm-values }}
\ No newline at end of file
diff --git a/entry.sh b/entry.sh
new file mode 100755
index 0000000..8da4796
--- /dev/null
+++ b/entry.sh
@@ -0,0 +1,320 @@
+#!/bin/sh -l
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+ACTION=$1
+VERSION=$2
+ASK_CONFIG=$3
+DOCKER_REPO_USERNAME=$4
+DOCKER_REPO_PASSWORD=$5
+CHART_GIT=$6
+CHART_BRANCH=$7
+CHART_PATH=$8
+TEST_CODE_GIT=${9}
+TEST_CODE_BRANCH=${10}
+TEST_CODE_PATH=${11}
+TEST_CMD_BASE=${12}
+JOB_INDEX=${13}
+HELM_VALUES=${14}
+
+export VERSION
+export CHART_GIT
+export CHART_BRANCH
+export CHART_PATH
+export REPO_NAME=`echo ${GITHUB_REPOSITORY#*/} | sed -e "s/\//-/g" | cut 
-c1-36 | tr '[A-Z]' '[a-z]'`
+export WORKFLOW_NAME=${GITHUB_WORKFLOW}
+export RUN_ID=${GITHUB_RUN_ID}
+export TEST_CODE_GIT
+export TEST_CODE_BRANCH
+export TEST_CODE_PATH
+export YAML_VALUES=`echo "${HELM_VALUES}" | sed -s 's/^/          /g'`
+
+echo "Start test version: ${GITHUB_REPOSITORY}@${VERSION}"
+
+echo "************************************"
+echo "*          Set config...           *"
+echo "************************************"
+mkdir -p ${HOME}/.kube
+kube_config=$(echo "${ASK_CONFIG}" | base64 -d)
+echo "${kube_config}" > ${HOME}/.kube/config
+export KUBECONFIG="${HOME}/.kube/config"
+
+VELA_APP_TEMPLATE='
+apiVersion: core.oam.dev/v1beta1
+kind: Application
+metadata:
+  name: ${VELA_APP_NAME}
+  description: ${REPO_NAME}-${WORKFLOW_NAME}-${RUN_ID}@${VERSION}
+spec:
+  components:
+    - name: ${REPO_NAME}
+      type: helm
+      properties:
+        chart: ${CHART_PATH}
+        git:
+          branch: ${CHART_BRANCH}
+        repoType: git
+        retries: 3
+        secretRef: \047\047
+        url: ${CHART_GIT}
+        values:
+${YAML_VALUES}'
+
+echo -e "${VELA_APP_TEMPLATE}" > ./velaapp.yaml
+sed -i '1d' ./velaapp.yaml
+
+env_uuid=${REPO_NAME}-${GITHUB_RUN_ID}-${JOB_INDEX}
+
+
+if [ ${ACTION} == "deploy" ]; then
+  echo "************************************"
+  echo "*     Create env and deploy...     *"
+  echo "************************************"
+
+  echo ${VERSION}: ${env_uuid} deploy start
+
+  vela env init ${env_uuid} --namespace ${env_uuid}
+
+  export VELA_APP_NAME=${env_uuid}
+  envsubst < ./velaapp.yaml > velaapp-${REPO_NAME}.yaml
+  cat velaapp-${REPO_NAME}.yaml
+
+  vela env set ${env_uuid}
+  vela up -f "velaapp-${REPO_NAME}.yaml"
+
+  app=${env_uuid}
+
+  status=`vela status ${app} -n ${app}`
+  echo $status
+  res=`echo $status | grep "Create helm release successfully"`
+  let count=0
+  while [ -z "$res" ]
+  do
+      if [ $count -gt 120 ]; then
+        echo "env ${app} deploy timeout..."
+        exit 1
+      fi
+      echo "waiting for env ${app} ready..."
+      sleep 5
+      status=`vela status ${app} -n ${app}`
+      stopped=`echo $status | grep "not found"`
+      if [ ! -z "$stopped" ]; then
+          echo "env ${app} deploy stopped..."
+          exit 1
+      fi
+      res=`echo $status | grep "Create helm release successfully"`
+      let count=${count}+1
+  done
+fi
+
+TEST_POD_TEMPLATE='
+apiVersion: v1
+kind: Pod
+metadata:
+  name: test-${ns}
+  namespace: ${ns}
+spec:
+  restartPolicy: Never
+  containers:
+  - name: test-${ns}
+    image: cloudnativeofalibabacloud/test-runner:v0.0.1
+    resources:
+          limits:
+            cpu: "8"
+            memory: "8Gi"
+          requests:
+            cpu: "8"
+            memory: "8Gi"
+    env:
+    - name: CODE
+      value: ${TEST_CODE_GIT}
+    - name: BRANCH
+      value: ${TEST_CODE_BRANCH}
+    - name: CODE_PATH
+      value: ${TEST_CODE_PATH}
+    - name: CMD
+      value: ${TEST_CMD}
+    - name: ALL_IP
+      value: ${ALL_IP}
+'
+
+echo -e "${TEST_POD_TEMPLATE}" > ./testpod.yaml
+sed -i '1d' ./testpod.yaml
+
+if [ ${ACTION} == "test" ]; then
+  echo "************************************"
+  echo "*            E2E Test...           *"
+  echo "************************************"
+
+  ns=${env_uuid}
+
+  echo namespace: $ns
+  all_pod_name=`kubectl get pods --no-headers -o 
custom-columns=":metadata.name" -n ${ns}`
+  ALL_IP=""
+  for pod in $all_pod_name;
+  do
+      POD_HOST=$(kubectl get pod ${pod} --template={{.status.podIP}} -n ${ns})
+      ALL_IP=${pod}:${POD_HOST},${ALL_IP}
+  done
+
+  echo $ALL_IP
+  echo $TEST_CODE_GIT
+  echo $TEST_CMD_BASE
+
+  export ALL_IP
+  export ns
+  is_mvn_cmd=`echo $TEST_CMD_BASE | grep "mvn"`
+  if [ ! -z "$is_mvn_cmd" ]; then
+      TEST_CMD="$TEST_CMD_BASE -DALL_IP=${ALL_IP}"
+  else
+      TEST_CMD=$TEST_CMD_BASE
+  fi
+  echo $TEST_CMD
+  export TEST_CMD
+
+  envsubst < ./testpod.yaml > ./testpod-${ns}.yaml
+  cat ./testpod-${ns}.yaml
+
+  kubectl apply -f ./testpod-${ns}.yaml
+
+  sleep 5
+
+  pod_status=`kubectl get pod test-${ns} --template={{.status.phase}} -n ${ns}`
+
+  while [ "${pod_status}" == "Pending" ] || [ "${pod_status}" == "Running" ]
+  do
+      echo waiting for test-${ns} test done...
+      sleep 5
+      pod_status=`kubectl get pod test-${ns} --template={{.status.phase}} -n 
${ns}`
+      test_done=`kubectl exec -i test-${ns} -n ${ns} -- ls /root | grep 
testdone`
+      if [ ! -z "$test_done" ]; then
+        echo "Test status: test done"
+        if [ ! -z "$is_mvn_cmd" ]; then
+          if [ ! -d "./test_report" ]; then
+            echo "Copy test reports"
+            kubectl cp --retries=10 test-${ns}:/root/testlog.txt testlog.txt 
-n ${ns}
+            mkdir -p test_report
+            cd test_report
+            kubectl cp --retries=10 
test-${ns}:/root/code/${TEST_CODE_PATH}/target/surefire-reports/. . -n ${ns}
+            rm -rf *.txt
+            ls
+            cd -
+          fi
+        fi
+      fi
+  done
+
+  exit_code=`kubectl get pod test-${ns} 
--output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}" -n 
${ns}`
+  kubectl delete pod test-${ns} -n ${ns}
+  echo E2E Test exit code: ${exit_code}
+  exit ${exit_code}
+fi
+
+if [ ${ACTION} == "test_local" ]; then
+  echo "************************************"
+  echo "*        E2E Test local...         *"
+  echo "************************************"
+
+  wget 
https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz
+  tar -zxvf apache-maven-3.8.7-bin.tar.gz -C /opt/
+  export PATH=$PATH:/opt/apache-maven-3.8.7/bin
+
+  ns=${env_uuid}
+
+  echo namespace: $ns
+  all_pod_name=`kubectl get pods --no-headers -o 
custom-columns=":metadata.name" -n ${ns}`
+  ALL_IP=""
+  for pod in $all_pod_name;
+  do
+      label=`kubectl get pod ${pod} 
--output="jsonpath={.metadata.labels.app\.kubernetes\.io/name}" -n ${ns}`
+      pod_port=`kubectl get -o json services 
--selector="app.kubernetes.io/name=${label}" -n ${ns} | jq -r 
'.items[].spec.ports[].port'`
+      echo "${pod}: ${pod_port}"
+      for port in ${pod_port};
+      do
+          kubectl port-forward ${pod} ${port}:${port} -n ${ns} &
+          res=$?
+          if [ ${res} -ne 0 ]; then
+            echo "kubectl port-forward error: ${pod} ${port}:${port}"
+            exit ${res}
+          fi
+      done
+      ALL_IP=${pod}:"127.0.0.1",${ALL_IP}
+      sleep 3
+  done
+
+  echo $ALL_IP
+  echo $TEST_CODE_GIT
+  echo $TEST_CMD_BASE
+
+  export ALL_IP
+  export ns
+  is_mvn_cmd=`echo $TEST_CMD_BASE | grep "mvn"`
+  if [ ! -z "$is_mvn_cmd" ]; then
+      TEST_CMD="$TEST_CMD_BASE -DALL_IP=${ALL_IP}"
+  else
+      TEST_CMD=$TEST_CMD_BASE
+  fi
+  echo $TEST_CMD
+
+  git clone $TEST_CODE_GIT -b $TEST_CODE_BRANCH code
+
+  cd code
+  cd $TEST_CODE_PATH
+  ${TEST_CMD}
+  exit_code=$?
+
+  killall kubectl
+  exit ${exit_code}
+fi
+
+if [ ${ACTION} == "clean" ]; then
+    echo "************************************"
+    echo "*       Delete app and env...      *"
+    echo "************************************"
+
+    env=${env_uuid}
+
+    vela delete ${env} -n ${env} -y
+    all_pod_name=`kubectl get pods --no-headers -o 
custom-columns=":metadata.name" -n ${env}`
+    for pod in $all_pod_name;
+    do
+      kubectl delete pod ${pod} -n ${env}
+    done
+
+    sleep 30
+
+    kubectl proxy &
+    PID=$!
+    sleep 3
+
+    DELETE_ENV=${env}
+
+    vela env delete ${DELETE_ENV} -y
+    sleep 3
+    kubectl delete namespace ${DELETE_ENV} --wait=false
+    kubectl get ns ${DELETE_ENV} -o json | jq '.spec.finalizers=[]' > 
ns-without-finalizers.json
+    cat ns-without-finalizers.json
+    curl -X PUT http://localhost:8001/api/v1/namespaces/${DELETE_ENV}/finalize 
-H "Content-Type: application/json" --data-binary @ns-without-finalizers.json
+
+    kill $PID
+fi
+
+if [ ${ACTION} == "try" ]; then
+  kubectl get pods --all-namespaces
+fi
+
+
diff --git a/test-runner/Dockerfile-test-runner 
b/test-runner/Dockerfile-test-runner
new file mode 100644
index 0000000..ef6a48d
--- /dev/null
+++ b/test-runner/Dockerfile-test-runner
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+FROM eclipse-temurin:8-jdk-centos7
+
+ENV LANG C.UTF-8
+
+WORKDIR /root
+COPY code_run.sh /root/code_run.sh
+RUN wget 
https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz
+RUN chmod 755 /root/code_run.sh
+RUN tar -xvf /root/apache-maven-3.8.7-bin.tar.gz -C /opt/
+COPY settings.xml /opt/apache-maven-3.8.7/conf
+
+RUN yum install unzip curl git epel-release gettext jq wget psmisc -y
+RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s 
https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
+RUN install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
+RUN curl -fsSl https://kubevela.net/script/install.sh | bash
+
+WORKDIR /root
+CMD ["/bin/bash", "-c", "./code_run.sh"]
\ No newline at end of file
diff --git a/test-runner/code_run.sh b/test-runner/code_run.sh
new file mode 100644
index 0000000..5f9fa9f
--- /dev/null
+++ b/test-runner/code_run.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+export M2_HOME=/opt/apache-maven-3.8.7
+export MAVEN_HOME=/opt/apache-maven-3.8.7
+export PATH=${M2_HOME}/bin:${PATH}
+
+git clone $CODE -b $BRANCH code 
+
+cd code
+cd $CODE_PATH
+$CMD > /root/testlog.txt
+res=$?
+# wait for result collect
+touch /root/testdone
+sleep 60
+exit $res
diff --git a/test-runner/settings.xml b/test-runner/settings.xml
new file mode 100644
index 0000000..3ba0b82
--- /dev/null
+++ b/test-runner/settings.xml
@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<!--
+ | This is the configuration file for Maven. It can be specified at two levels:
+ |
+ |  1. User Level. This settings.xml file provides configuration for a single 
user,
+ |                 and is normally provided in ${user.home}/.m2/settings.xml.
+ |
+ |                 NOTE: This location can be overridden with the CLI option:
+ |
+ |                 -s /path/to/user/settings.xml
+ |
+ |  2. Global Level. This settings.xml file provides configuration for all 
Maven
+ |                 users on a machine (assuming they're all using the same 
Maven
+ |                 installation). It's normally provided in
+ |                 ${maven.conf}/settings.xml.
+ |
+ |                 NOTE: This location can be overridden with the CLI option:
+ |
+ |                 -gs /path/to/global/settings.xml
+ |
+ | The sections in this sample file are intended to give you a running start at
+ | getting the most out of your Maven installation. Where appropriate, the 
default
+ | values (values used when the setting is not specified) are provided.
+ |
+ |-->
+<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0";
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 
https://maven.apache.org/xsd/settings-1.2.0.xsd";>
+    <!-- localRepository
+     | The path to the local repository maven will use to store artifacts.
+     |
+     | Default: ${user.home}/.m2/repository
+    <localRepository>/path/to/local/repo</localRepository>
+    -->
+
+    <!-- interactiveMode
+     | This will determine whether maven prompts you when it needs input. If 
set to false,
+     | maven will use a sensible default value, perhaps based on some other 
setting, for
+     | the parameter in question.
+     |
+     | Default: true
+    <interactiveMode>true</interactiveMode>
+    -->
+
+    <!-- offline
+     | Determines whether maven should attempt to connect to the network when 
executing a build.
+     | This will have an effect on artifact downloads, artifact deployment, 
and others.
+     |
+     | Default: false
+    <offline>false</offline>
+    -->
+
+    <!-- pluginGroups
+     | This is a list of additional group identifiers that will be searched 
when resolving plugins by their prefix, i.e.
+     | when invoking a command line like "mvn prefix:goal". Maven will 
automatically add the group identifiers
+     | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not 
already contained in the list.
+     |-->
+    <pluginGroups>
+        <!-- pluginGroup
+         | Specifies a further group identifier to use for plugin lookup.
+        <pluginGroup>com.your.plugins</pluginGroup>
+        -->
+    </pluginGroups>
+
+    <!-- proxies
+     | This is a list of proxies which can be used on this machine to connect 
to the network.
+     | Unless otherwise specified (by system property or command-line switch), 
the first proxy
+     | specification in this list marked as active will be used.
+     |-->
+    <proxies>
+        <!-- proxy
+         | Specification for one proxy, to be used in connecting to the 
network.
+         |
+        <proxy>
+          <id>optional</id>
+          <active>true</active>
+          <protocol>http</protocol>
+          <username>proxyuser</username>
+          <password>proxypass</password>
+          <host>proxy.host.net</host>
+          <port>80</port>
+          <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
+        </proxy>
+        -->
+    </proxies>
+
+    <!-- servers
+     | This is a list of authentication profiles, keyed by the server-id used 
within the system.
+     | Authentication profiles can be used whenever maven must make a 
connection to a remote server.
+     |-->
+    <servers>
+        <!-- server
+         | Specifies the authentication information to use when connecting to 
a particular server, identified by
+         | a unique name within the system (referred to by the 'id' attribute 
below).
+         |
+         | NOTE: You should either specify username/password OR 
privateKey/passphrase, since these pairings are
+         |       used together.
+         |
+        <server>
+          <id>deploymentRepo</id>
+          <username>repouser</username>
+          <password>repopwd</password>
+        </server>
+        -->
+
+        <!-- Another sample, using keys to authenticate.
+        <server>
+          <id>siteServer</id>
+          <privateKey>/path/to/private/key</privateKey>
+          <passphrase>optional; leave empty if not used.</passphrase>
+        </server>
+        -->
+    </servers>
+
+    <!-- mirrors
+     | This is a list of mirrors to be used in downloading artifacts from 
remote repositories.
+     |
+     | It works like this: a POM may declare a repository to use in resolving 
certain artifacts.
+     | However, this repository may have problems with heavy traffic at times, 
so people have mirrored
+     | it to several places.
+     |
+     | That repository definition will have a unique id, so we can create a 
mirror reference for that
+     | repository, to be used as an alternate download site. The mirror site 
will be the preferred
+     | server for that repository.
+     |-->
+    <mirrors>
+        <!-- mirror
+         | Specifies a repository mirror site to use instead of a given 
repository. The repository that
+         | this mirror serves has an ID that matches the mirrorOf element of 
this mirror. IDs are used
+         | for inheritance and direct lookup purposes, and must be unique 
across the set of mirrors.
+         |
+        <mirror>
+          <id>mirrorId</id>
+          <mirrorOf>repositoryId</mirrorOf>
+          <name>Human Readable Name for this Mirror.</name>
+          <url>http://my.repository.com/repo/path</url>
+        </mirror>
+         -->
+        <mirror>
+            <id>maven-default-http-blocker</id>
+            <mirrorOf>external:http:*</mirrorOf>
+            <name>Pseudo repository to mirror external repositories initially 
using HTTP.</name>
+            <url>http://0.0.0.0/</url>
+            <blocked>true</blocked>
+        </mirror>
+        <mirror>
+            <id>aliyunmaven</id>
+            <mirrorOf>*</mirrorOf>
+            <name>aliyun</name>
+            <url>https://maven.aliyun.com/repository/public</url>
+        </mirror>
+    </mirrors>
+
+    <!-- profiles
+     | This is a list of profiles which can be activated in a variety of ways, 
and which can modify
+     | the build process. Profiles provided in the settings.xml are intended 
to provide local machine-
+     | specific paths and repository locations which allow the build to work 
in the local environment.
+     |
+     | For example, if you have an integration testing plugin - like cactus - 
that needs to know where
+     | your Tomcat instance is installed, you can provide a variable here such 
that the variable is
+     | dereferenced during the build process to configure the cactus plugin.
+     |
+     | As noted above, profiles can be activated in a variety of ways. One way 
- the activeProfiles
+     | section of this document (settings.xml) - will be discussed later. 
Another way essentially
+     | relies on the detection of a system property, either matching a 
particular value for the property,
+     | or merely testing its existence. Profiles can also be activated by JDK 
version prefix, where a
+     | value of '1.4' might activate a profile when the build is executed on a 
JDK version of '1.4.2_07'.
+     | Finally, the list of active profiles can be specified directly from the 
command line.
+     |
+     | NOTE: For profiles defined in the settings.xml, you are restricted to 
specifying only artifact
+     |       repositories, plugin repositories, and free-form properties to be 
used as configuration
+     |       variables for plugins in the POM.
+     |
+     |-->
+    <profiles>
+        <!-- profile
+         | Specifies a set of introductions to the build process, to be 
activated using one or more of the
+         | mechanisms described above. For inheritance purposes, and to 
activate profiles via <activatedProfiles/>
+         | or the command line, profiles have to have an ID that is unique.
+         |
+         | An encouraged best practice for profile identification is to use a 
consistent naming convention
+         | for profiles, such as 'env-dev', 'env-test', 'env-production', 
'user-jdcasey', 'user-brett', etc.
+         | This will make it more intuitive to understand what the set of 
introduced profiles is attempting
+         | to accomplish, particularly when you only have a list of profile 
id's for debug.
+         |
+         | This profile example uses the JDK version to trigger activation, 
and provides a JDK-specific repo.
+        <profile>
+          <id>jdk-1.4</id>
+
+          <activation>
+            <jdk>1.4</jdk>
+          </activation>
+
+          <repositories>
+            <repository>
+              <id>jdk14</id>
+              <name>Repository for JDK 1.4 builds</name>
+              <url>http://www.myhost.com/maven/jdk14</url>
+              <layout>default</layout>
+              <snapshotPolicy>always</snapshotPolicy>
+            </repository>
+          </repositories>
+        </profile>
+        -->
+
+        <!--
+         | Here is another profile, activated by the system property 
'target-env' with a value of 'dev',
+         | which provides a specific path to the Tomcat instance. To use this, 
your plugin configuration
+         | might hypothetically look like:
+         |
+         | ...
+         | <plugin>
+         |   <groupId>org.myco.myplugins</groupId>
+         |   <artifactId>myplugin</artifactId>
+         |
+         |   <configuration>
+         |     <tomcatLocation>${tomcatPath}</tomcatLocation>
+         |   </configuration>
+         | </plugin>
+         | ...
+         |
+         | NOTE: If you just wanted to inject this configuration whenever 
someone set 'target-env' to
+         |       anything, you could just leave off the <value/> inside the 
activation-property.
+         |
+        <profile>
+          <id>env-dev</id>
+
+          <activation>
+            <property>
+              <name>target-env</name>
+              <value>dev</value>
+            </property>
+          </activation>
+
+          <properties>
+            <tomcatPath>/path/to/tomcat/instance</tomcatPath>
+          </properties>
+        </profile>
+        -->
+    </profiles>
+
+    <!-- activeProfiles
+     | List of profiles that are active for all builds.
+     |
+    <activeProfiles>
+      <activeProfile>alwaysActiveProfile</activeProfile>
+      <activeProfile>anotherAlwaysActiveProfile</activeProfile>
+    </activeProfiles>
+    -->
+</settings>
\ No newline at end of file

Reply via email to