Skip to content

Commit 284300c

Browse files
jerjoulesv
authored andcommitted
Add jenkins scripts & test for sparkjava (GoogleCloudPlatform#538)
1 parent cb03af3 commit 284300c

File tree

6 files changed

+119
-13
lines changed

6 files changed

+119
-13
lines changed

appengine/endpoints-frameworks-v2/discovery/build.gradle

+5-4
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ dependencies {
4848
}
4949

5050
appengine { // App Engine tasks configuration
51-
run { // local (dev_appserver) configuration (standard environments only)
52-
53-
}
54-
5551
deploy { // deploy configuration
52+
version = findProperty("appengine.deploy.version")
5653

54+
def promoteProp = findProperty("appengine.deploy.promote")
55+
if (promoteProp != null) {
56+
promote = new Boolean(promoteProp)
57+
}
5758
}
5859
}
5960

appengine/endpoints-frameworks-v2/discovery/Jenkins.sh renamed to appengine/endpoints-frameworks-v2/discovery/jenkins.sh

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# Copyright 2017 Google Inc.
44
#
@@ -48,7 +48,8 @@ sed -i'.bak' -e "s/hello world!/hello version-${GOOGLE_VERSION_ID}!/g" src/main/
4848

4949
# Test with Maven
5050
mvn clean appengine:deploy \
51-
-Dapp.deploy.version="${GOOGLE_VERSION_ID}"
51+
-Dapp.deploy.version="${GOOGLE_VERSION_ID}" \
52+
-Dapp.deploy.promote=false
5253

5354
# End-2-End tests
5455
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}"
@@ -57,17 +58,16 @@ TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}"
5758
mvn clean
5859

5960
# Test with Gradle
60-
# Update build.gradle
61-
sed -i'.bak' -e "s/deploy {/deploy {\n version='${GOOGLE_VERSION_ID}'/g" build.gradle
62-
6361
# Modify Greetings.java for Gradle
64-
sed -i'.bak' -e "s/hello version-${GOOGLE_VERSION_ID}!/hello version-gradle-${GOOGLE_VERSION_ID}!/g" src/main/java/com/example/helloendpoints/Greetings.java
62+
sed -i'.bak' -e "s/hello version-${GOOGLE_VERSION_ID}!/hello version-${GOOGLE_VERSION_ID}!/g" src/main/java/com/example/helloendpoints/Greetings.java
6563

6664
# Deploy Gradle
67-
gradle appengineDeploy
65+
gradle -Pappengine.deploy.promote=false \
66+
-Pappengine.deploy.version="${GOOGLE_VERSION_ID}" \
67+
appengineDeploy
6868

6969
# End-2-End tests
70-
TestEndpoints "${GOOGLE_PROJECT_ID}" "gradle-${GOOGLE_VERSION_ID}"
70+
TestEndpoints "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}"
7171

7272
# Clean
7373
gradle clean

appengine/endpoints-frameworks-v2/discovery/src/main/java/com/example/helloendpoints/Greetings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class Greetings {
4343
public static ArrayList<HelloGreeting> greetings = new ArrayList<HelloGreeting>();
4444

4545
static {
46-
greetings.add(new HelloGreeting("hello world!"));
46+
greetings.add(new HelloGreeting("hello version-jerjou-test!"));
4747
greetings.add(new HelloGreeting("goodbye world!"));
4848
}
4949
//[END api_def]

appengine/helloworld/jenkins.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -xe
18+
19+
mvn clean appengine:update \
20+
-Dappengine.additionalParams="--service_account_json_key_file=${GOOGLE_APPLICATION_CREDENTIALS}" \
21+
-Dappengine.appId="${GOOGLE_PROJECT_ID}" \
22+
-Dappengine.version="${GOOGLE_VERSION_ID}" \
23+
-DskipTests=true
24+
25+
curl -f "http://${GOOGLE_VERSION_ID}-dot-${GOOGLE_PROJECT_ID}.appspot.com/"

flexible/sparkjava/jenkins.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Fail on non-zero return and print command to stdout
18+
set -xe
19+
20+
# Jenkins Test Script
21+
function runtests () {
22+
curl -X GET \
23+
"https://${2}-dot-${1}.appspot.com/api/users" | \
24+
grep "^\\["
25+
}
26+
27+
# Jenkins provides values for GOOGLE_PROJECT_ID and GOOGLE_VERSION_ID
28+
29+
# Test with Maven
30+
mvn clean appengine:deploy \
31+
-Dapp.deploy.version="${GOOGLE_VERSION_ID}" \
32+
-Dapp.deploy.promote=false
33+
34+
# End-2-End tests
35+
runtests "${GOOGLE_PROJECT_ID}" "${GOOGLE_VERSION_ID}"

jenkins.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2017 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -x
18+
shopt -s globstar
19+
20+
delete_app_version() {
21+
yes | gcloud --project="$GOOGLE_PROJECT_ID" \
22+
app versions delete "$GOOGLE_VERSION_ID"
23+
}
24+
handle_error() {
25+
errcode=$? # Remember the error code so we can exit with it after cleanup
26+
27+
# Clean up
28+
delete_app_version
29+
30+
exit $errcode
31+
}
32+
trap handle_error ERR
33+
34+
# First, style-check the shell scripts
35+
shellcheck ./**/*.sh
36+
37+
# Find all jenkins.sh's and run them.
38+
find . -mindepth 2 -maxdepth 5 -name jenkins.sh -type f | while read path; do
39+
(
40+
pushd "${path%jenkins.sh}"
41+
/bin/bash ./jenkins.sh
42+
)
43+
done
44+
45+
delete_app_version

0 commit comments

Comments
 (0)