-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from stephenashank/feature/cicd
Onboard OAuth plugin in team CI server.
- Loading branch information
Showing
3 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,52 @@ | ||
// Build the plugin using https://github.com/jenkins-infra/pipeline-library | ||
buildPlugin(platforms: ['linux'], jenkinsVersions: [null, '2.107.2'], failFast: false) | ||
/* | ||
* Copyright 2019 Google Inc. | ||
* | ||
* Licensed 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. | ||
*/ | ||
pipeline { | ||
agent { | ||
kubernetes { | ||
cloud 'kubernetes' | ||
label 'maven-pod' | ||
yamlFile 'jenkins/maven-pod.yaml' | ||
} | ||
} | ||
|
||
environment { | ||
GOOGLE_PROJECT_ID = "${OAUTH_IT_PROJECT_ID}" | ||
BUILD_ARTIFACTS_BUCKET = "${OAUTH_IT_BUCKET}" | ||
BUILD_ARTIFACTS = "build-${BRANCH_NAME}-${BUILD_ID}.tar.gz" | ||
} | ||
|
||
stages { | ||
stage("Build and test") { | ||
steps { | ||
container('maven') { | ||
withCredentials([[$class: 'StringBinding', credentialsId: env.OAUTH_IT_CRED_ID, variable: 'GOOGLE_CREDENTIALS']]) { | ||
catchError { | ||
// build | ||
sh "mvn clean package -ntp" | ||
|
||
// run tests | ||
sh "mvn verify -ntp" | ||
} | ||
|
||
sh "jenkins/saveAndCompress.sh" | ||
step([$class: 'ClassicUploadStep', credentialsId: env.OAUTH_BUCKET_CRED_ID, bucket: "gs://${BUILD_ARTIFACTS_BUCKET}", pattern: env.BUILD_ARTIFACTS]) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2019 Google Inc. | ||
# | ||
# Licensed 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. | ||
|
||
apiVersion: v1 | ||
kind: Pod | ||
spec: | ||
containers: | ||
- name: maven | ||
image: maven:3.6.2-jdk-8 | ||
command: ['cat'] | ||
tty: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
# Copyright 2019 Google Inc. | ||
# | ||
# Licensed 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. | ||
pwd | ||
mkdir result | ||
|
||
# The files will only exist if maven reaches the corresponding phase of the build | ||
function cpe() { | ||
if [[ -e target/$1 ]]; then | ||
cp -rv target/$1 result | ||
else | ||
echo "target/$1 not copied, check the completed build phases." | ||
fi | ||
} | ||
|
||
# Copy over the important artifacts | ||
cpe google-oauth-plugin.hpi | ||
cpe failsafe-reports | ||
cpe surefire-reports | ||
|
||
# Compress the artifacts for upload | ||
tar -zcvf ${BUILD_ARTIFACTS} result |