Update Nomulus release pipeline

Refactor out the build and package logic to a reusable script. Also removed the gradle task flag to skip lint check, as failing lint check is no longer a fatal error.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=245296563
This commit is contained in:
jianglai 2019-04-25 13:29:30 -07:00
parent 4895f455d8
commit 94aa5cd6ec
3 changed files with 34 additions and 41 deletions

View file

@ -12,16 +12,26 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
#
# This script moves GAE artifacts for a given environment to a designated location. # This script builds the GAE artifacts for a given environment, moves the
# artifacts for all services to a designated location, and then creates a
# tarball from there.
if [ $# -ne 2 ]; if [ $# -ne 2 ];
then then
echo "Usage: $0 alpha|crash|sandbox|production destination." echo "Usage: $0 alpha|crash|sandbox|production <destination>"
exit 1 exit 1
fi fi
environment="$1"
dest="$2/$1" dest="$2/$1"
gcs_prefix="storage.googleapis.com/domain-registry-maven-repository"
cd gradle
./gradlew clean stage -Penvironment="${environment}" \
-PmavenUrl=https://"${gcs_prefix}"/maven \
-PpluginsUrl=https://"${gcs_prefix}"/plugins
cd -
mkdir -p "${dest}" mkdir -p "${dest}"
@ -29,3 +39,7 @@ for service in default pubapi backend tools
do do
mv gradle/services/"${service}"/build/staged-app "${dest}/${service}" mv gradle/services/"${service}"/build/staged-app "${dest}/${service}"
done done
cd "${dest}"
tar cvf ../../"${environment}.tar" .
cd -

View file

@ -3,71 +3,52 @@
# You will need access to a private registry, so be sure to install the docker # You will need access to a private registry, so be sure to install the docker
# credential helper. # credential helper.
# Then, in the root of a nomulus source tree, run: # Then, in the root of a nomulus source tree, run:
# cloud-build-local --config=cloudbuild-nomulus.yaml --dryrun=false --substitutions TAG_NAME=[TAG] . # cloud-build-local --config=cloudbuild-nomulus.yaml --dryrun=false \
# --substitutions TAG_NAME=[TAG] ..
# This will build the contents of the current directory and generate the # This will build the contents of the current directory and generate the
# nomulus war-files locally. # nomulus war-files locally.
# The PROJECT_ID is the current project name that gcloud uses. # The PROJECT_ID is the current project name that gcloud uses.
# You can add "--push true" to have the image pushed to GCR. # You can add "--push true" to have the image pushed to GCR.
# #
# To manually trigger a build on GCB, run: # To manually trigger a build on GCB, run:
# gcloud builds submit --config cloudbuild-nomulus.yaml --substitutions TAG_NAME=[TAG] . # gcloud builds submit --config cloudbuild-nomulus.yaml --substitutions TAG_NAME=[TAG] ..
# #
# To trigger a build automatically, follow the instructions below and add a trigger: # To trigger a build automatically, follow the instructions below and add a trigger:
# https://cloud.google.com/cloud-build/docs/running-builds/automate-builds # https://cloud.google.com/cloud-build/docs/running-builds/automate-builds
steps: steps:
# Set permissions correctly. Not sure why it is necessary, but it is. # Set permissions correctly. Not sure why it is necessary, but it is.
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
entrypoint: /bin/bash
args: ['chown', '-R', 'root:root', '.'] args: ['chown', '-R', 'root:root', '.']
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
entrypoint: /bin/bash
args: ['chmod', '-R', '777', '.'] args: ['chmod', '-R', '777', '.']
# Create a directory to store the artifacts # Create a directory to store the artifacts
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
entrypoint: /bin/bash
args: ['mkdir', 'nomulus'] args: ['mkdir', 'nomulus']
# Run tests # Run tests
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
args: ['./gradlew', 'test'] args: ['./gradlew', 'test']
dir: 'gradle' dir: 'gradle'
# Build the deployment files for sandbox. # Build and package the deployment files for alpha.
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
args: args: ['release/build_nomulus_for_env.sh', 'alpha', 'nomulus']
- './gradlew' # Build and package the deployment files for crash.
- 'stage'
- '-x'
- 'autoLintGradle'
- '-Penvironment=sandbox'
- '-PmavenUrl=gcs://domain-registry-maven-repository/maven'
- '-PpluginsUrl=gcs://domain-registry-maven-repository/plugins'
dir: 'gradle'
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
entrypoint: bin/bash args: ['release/build_nomulus_for_env.sh', 'crash', 'nomulus']
args: ['./move_artifacts.sh', 'sandbox', 'nomulus'] # Build and package the deployment files for sandbox.
# Build the deployment files for crash.
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
args: args: ['release/build_nomulus_for_env.sh', 'sandbox', 'nomulus']
- './gradlew' # Build and package the deployment files for production.
- 'stage'
- '-x'
- 'autoLintGradle'
- '-Penvironment=crash'
- '-PmavenUrl=gcs://domain-registry-maven-repository/maven'
- '-PpluginsUrl=gcs://domain-registry-maven-repository/plugins'
dir: 'gradle'
- name: 'gcr.io/${PROJECT_ID}/builder:latest' - name: 'gcr.io/${PROJECT_ID}/builder:latest'
entrypoint: bin/bash args: ['release/build_nomulus_for_env.sh', 'production', 'nomulus']
args: ['./move_artifacts.sh', 'crash', 'nomulus'] # The tarballs to upload to GCS.
# Create the uber tarball including all environments.
- name: 'gcr.io/${PROJECT_ID}/builder:latest'
entrypoint: bin/bash
args: ['tar', 'cvf', '../nomulus.tar', '.']
dir: 'nomulus'
# The tarball to upload to GCS.
artifacts: artifacts:
objects: objects:
location: 'gs://${PROJECT_ID}-deploy/${TAG_NAME}' location: 'gs://${PROJECT_ID}-deploy/${TAG_NAME}'
paths: ['nomulus.tar'] paths:
- 'alpha.tar'
- 'crash.tar'
- 'sandbox.tar'
- 'production.tar'
timeout: 3600s timeout: 3600s
options: options:
machineType: 'N1_HIGHCPU_8' machineType: 'N1_HIGHCPU_8'

View file

@ -24,8 +24,6 @@ steps:
- './gradlew' - './gradlew'
- ':proxy:test' - ':proxy:test'
- ':proxy:deployJar' - ':proxy:deployJar'
- '-x'
- 'autoLintGradle'
- '-PmavenUrl=https://storage.googleapis.com/domain-registry-maven-repository/maven' - '-PmavenUrl=https://storage.googleapis.com/domain-registry-maven-repository/maven'
- '-PpluginsUrl=https://storage.googleapis.com/domain-registry-maven-repository/plugins' - '-PpluginsUrl=https://storage.googleapis.com/domain-registry-maven-repository/plugins'
dir: 'gradle' dir: 'gradle'