Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
f57288c
switched from node to pipeline
justwes2 Jun 25, 2019
3d3c116
tested jenkinsfile read
justwes2 Jun 25, 2019
c57ebf1
working on the correct jenkinsfile this time
justwes2 Jun 25, 2019
f36daa6
moved workspace dec
justwes2 Jun 25, 2019
eb6c1d2
added stages wrapper
justwes2 Jun 25, 2019
0eeac54
updated jenkinsfile.integration
justwes2 Jun 25, 2019
5f23671
more updates to jenkinsfile
justwes2 Jun 25, 2019
30872a5
working on env vars
justwes2 Jun 25, 2019
4c53a5f
removed creds
justwes2 Jun 25, 2019
c051233
fixed comment issue
justwes2 Jun 25, 2019
06d5542
fixed object type issue
justwes2 Jun 25, 2019
f4b19a4
debugging version conflict
justwes2 Jun 25, 2019
02c71a5
added version constraints
justwes2 Jun 25, 2019
767e30e
commented out infra creation
justwes2 Jun 25, 2019
eb73dac
removed version constrants
justwes2 Jun 25, 2019
ca19d70
switching to tf.12
justwes2 Jun 25, 2019
106486a
uncommenting all steps
justwes2 Jun 25, 2019
d06db3c
added terraform destroy pipeline
justwes2 Jun 25, 2019
231ca2e
updated main jenkinsfile, added public ip to tf
justwes2 Jun 26, 2019
39d1c13
fixed bool format
justwes2 Jun 26, 2019
d6357b2
fixed bool for real
justwes2 Jun 26, 2019
2ef22c5
Merge branch 'master' into feature/004-terraform
justwes2 Jun 26, 2019
eb596dc
added role
Tony-Lutz Jun 27, 2019
78afeba
changing vpc
Tony-Lutz Jun 28, 2019
062c8e9
commented out subnet
Tony-Lutz Jun 28, 2019
fa99661
updated vpc, subnet, and other values
Tony-Lutz Jun 28, 2019
0c9d832
add first run list
Tony-Lutz Jun 28, 2019
02b4a51
updated runlist
Tony-Lutz Jun 28, 2019
21dc26d
test
bdealey Jun 28, 2019
4c6f5cd
added destroy before build
justwes2 Jun 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 129 additions & 77 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
node {
tools {"org.jenkinsci.plugins.terraform.TerraformInstallation" "terraform-0.11.10"}
pipeline {
agent any

tools {
"org.jenkinsci.plugins.terraform.TerraformInstallation" "terraform-0.11.10"
}

environment {
TF_HOME = tool('terraform-0.11.10')
Expand All @@ -9,93 +13,141 @@ node {
SECRET_KEY = credentials('jenkins-aws-secret-access-key')
}

echo "workspace directory is ${workspace}"
stages{
stage('checkout') {
steps {
checkout scm
echo "workspace directory is ${workspace}"
}
}

stage('checkout') {
checkout scm
}
stage('terraform destroy') {
steps {
dir('./terraform/prod'){
sh "terraform --version"
sh "echo 'Destroying old Infrastructure'"
sh "terraform destroy --auto-approve"
}
}
}

stage('check java') {
sh "java -version"
}
stage('check java') {
steps {
sh "java -version"
}
}

script {
version = sh (
script: "./gradlew properties -q | grep \"^version:\" | awk '{print \$2}'",
returnStdout: true
).trim()
sh "echo Building project in version: $version"
}
stage('get project version') {
steps {
script {
version = sh (
script: "./gradlew properties -q | grep \"^version:\" | awk '{print \$2}'",
returnStdout: true
).trim()
sh "echo Building project in version: $version"
}
}
}

stage('clean') {
steps {
sh "chmod +x gradlew"
sh "./gradlew clean --no-daemon"
}
}

stage('clean') {
sh "chmod +x gradlew"
sh "./gradlew clean --no-daemon"
}
stage('build') {
steps {
sh "./gradlew npm_install -Pprod -PnodeInstall --no-daemon"
}
}

stage('build') {
sh "./gradlew npm_install -Pprod -PnodeInstall --no-daemon"
}
stage('quality analysis') {
steps {
withSonarQubeEnv('sonarqube') {
sh "./gradlew sonarqube --no-daemon -PnodeInstall -Pprod"
}
}
}

stage('backend tests') {
steps {
script {
try {
sh "./gradlew test integrationTest -Pprod -PnodeInstall --no-daemon"
} catch(err) {
throw err
} finally {
junit '**/build/**/TEST-*.xml' }
}
}
}


stage('backend tests') {
try {
sh "./gradlew test integrationTest -Pprod -PnodeInstall --no-daemon"
} catch(err) {
throw err
} finally {
junit '**/build/**/TEST-*.xml' } }
stage('frontend tests') {
steps {
script {
try {
sh "./gradlew npm_run_test -Pprod -PnodeInstall --no-daemon"
} catch(err) {
throw err
} finally {
junit '**/build/test-results/TESTS-*.xml' }
}
}
}

stage('frontend tests') {
try {
sh "./gradlew npm_run_test -Pprod -PnodeInstall --no-daemon"
} catch(err) {
throw err
} finally {
junit '**/build/test-results/TESTS-*.xml'
}
}

stage('packaging') {
sh "./gradlew bootJar -x test -Pprod -PnodeInstall --no-daemon"
archiveArtifacts artifacts: '**/build/libs/*.jar', fingerprint: true
}
stage('packaging') {
steps {
sh "./gradlew bootJar -x test -Pprod -PnodeInstall --no-daemon"
archiveArtifacts artifacts: '**/build/libs/*.jar', fingerprint: true
}
}

stage ('Publish') {
nexusPublisher nexusInstanceId: 'stsnexus', nexusRepositoryId: 'maven-releases', packages: [[$class: 'MavenPackage', mavenAssetList: [[classifier: '', extension: '', filePath: "${workspace}/build/libs/devopsdemo-${version}.jar"]], mavenCoordinate: [artifactId: 'devops-demo', groupId: 'com.simpletechnologysolutions', packaging: 'jar', version: "${version}" ]]]
}
stage ('Publish') {
steps {
nexusPublisher nexusInstanceId: 'stsnexus', nexusRepositoryId: 'maven-releases', packages: [[$class: 'MavenPackage', mavenAssetList: [[classifier: '', extension: '', filePath: "${workspace}/build/libs/devopsdemo-${version}.jar"]], mavenCoordinate: [artifactId: 'devops-demo', groupId: 'com.simpletechnologysolutions', packaging: 'jar', version: "${version}" ]]]
}
}

stage('terraform init') {
dir('./terraform/prod'){
sh "echo 'Initializing Terraform'"
sh "terraform init -input=false"
}
}

stage('terraform plan'){
dir('./terraform/prod'){
sh "echo 'Planning Terraform Build'"
sh "terraform plan -var 'access_key=$ACCESS_KEY' -var 'secret_key=$SECRET_KEY'"
stage('terraform init') {
steps {
dir('./terraform/prod'){
sh "terraform --version"
sh "echo 'Initializing Terraform'"
sh "terraform init -input=false"
}
}
}
}

stage('terraform apply'){
steps {
script{
def apply = false
try {
input message: 'Can you please confirm the apply', ok: 'Ready to Apply the Config'
apply = true
} catch (err) {
apply = false
currentBuild.result = 'UNSTABLE'
}
if(apply){
dir('./terraform/prod'){
sh "echo 'Applying Terraform'"
sh 'terraform apply --auto-approve'
}
stage('terraform plan'){
steps {
dir('./terraform/prod'){
sh "echo 'Planning Terraform Build'"
sh "terraform plan"
}
}
}
}
}

stage('terraform apply'){
steps {
script{
def apply = false
try {
input message: 'Can you please confirm the apply', ok: 'Ready to Apply the Config'
apply = true
} catch (err) {
apply = false
currentBuild.result = 'UNSTABLE'
}
if(apply){
dir('./terraform/prod'){
sh "echo 'Applying Terraform'"
sh 'terraform apply --auto-approve'
}
}
}
}
}
}
}
57 changes: 57 additions & 0 deletions Jenkinsfile.destroy
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

//This pipeline should be run to destroy terraform resources
pipeline {
agent any

tools {
"org.jenkinsci.plugins.terraform.TerraformInstallation" "terraform-0.11.10"
}

environment {
TF_HOME = tool('terraform-0.11.10')
TF_IN_AUTOMATION = "true"
PATH = "$TF_HOME:$PATH"
ACCESS_KEY = credentials('jenkins-aws-secret-key-id')
SECRET_KEY = credentials('jenkins-aws-secret-access-key')
}

stages{
stage('checkout') {
steps {
checkout scm
echo "workspace directory is ${workspace}"
}
}

stage('terraform init') {
steps {
dir('./terraform/prod'){
sh "terraform --version"
sh "echo 'Initializing Terraform'"
sh "terraform init -input=false"
}
}
}

stage('terraform destroy'){
steps {
script{
def apply = false
try {
input message: 'Can you please confirm the destroy', ok: 'Ready to Destroy the Infrastructure'
apply = true
} catch (err) {
apply = false
currentBuild.result = 'UNSTABLE'
}
if(apply){
dir('./terraform/prod'){
sh "echo 'Applying Terraform'"
sh 'terraform destroy --auto-approve'
}
}
}
}
}
}
}
Loading