Skip to content

Commit

Permalink
deployement scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
NIS-PK409 authored and NIS-PK409 committed Dec 16, 2021
1 parent ab86d02 commit 34c64b2
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 1 deletion.
Binary file modified .DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,42 @@ dependencies {
compile 'org.codehaus.groovy:groovy-all:2.3.11'
}

task downloadArtifact {
def applicationName = (project.applicationName == '') ? "${project.name}".replace("-pipeline", "-service") : project.applicationName
println $applicationName
def artifactId = project.hasProperty('artifact_id') ? (artifact_id != '' ? artifact_id : URLEncoder.encode("[RELEASE]", "UTF-8")) : URLEncoder.encode("[RELEASE]", "UTF-8")
def artifactoryPath = appNameGroupMap[applicationName]
println "Artifactory Path : ${artifactoryPath}"
def deployProps = (targetEnvironment == 'production') ? prodDeployProps : nonProdDeployProps
def extension = (applicationName == warProjects[applicationName]) ? 'war' : 'jar'
def fileToDownload = "${applicationName}-${artifactId}.${extension}"
println "File to Download : ${fileToDownload}"
def artifactPathURL = "${deployProps.repo}/${artifactoryPath}/${applicationName}/${artifactId}/${fileToDownload}"

doLast {
download {
println "Application Name: ${applicationName}"
println "Artifact Path URL: ${artifactPathURL}"
src "${artifactPathURL}"
dest buildDir
username 'admin' //System.getenv("ARTIFACTORY_USERNAME")
password 'Admin123' //System.getenv("ARTIFACTORY_PASSWORD")
overwrite true
}
}
}

task wait {
doLast {
println("Waiting 15 seconds")
sleep(15000)
}
}

task deploy(dependsOn: ['downloadArtifact', 'wait']) {
wait.mustRunAfter downloadArtifact




}
61 changes: 61 additions & 0 deletions src/main/groovy/deploy-war.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/sh



echo "Done with upload-dgl-extension.sh"
if [ "$1" == "" ] ; then
echo "ERROR! Missing JAR name to be deployed."
echo "Usage: ./deploy-dgl-extension.sh <JAR_NAME>"
exit 0
fi

JAR_NAME=$1

PREFIX=${JAR_NAME%-*}

echo "Starting deploy of DGL extension ($JAR_NAME)..."
echo ""

cd /tmp

echo "Cleaning previous versions..."
echo "mv /home/stibosw/$PREFIX* /home/stibosw/old_recipes"
echo ""

OLD_RECIPE_LIST=`sudo -u stibosw ls /home/stibosw/ | grep $PREFIX`
echo $OLD_RECIPE_LIST
for old_recipe in $OLD_RECIPE_LIST
do
sudo -u stibosw mv /home/stibosw/$old_recipe /home/stibosw/old_recipes
done

echo "Copying jar to home folder..."
echo "sudo -u stibosw cp /tmp/$JAR_NAME /home/stibosw"
echo ""

sudo -u stibosw cp /tmp/$JAR_NAME /home/stibosw

echo ""
echo ""

VERSION_INDEX=${JAR_NAME%.*}
VERSION=${VERSION_INDEX##*-}

echo "Creating recipe for $PREFIX, version $VERSION..."
echo "sudo -u stibosw /opt/stibo/step/spot --package=/home/stibosw --target=$PREFIX,$VERSION --insecure=E9950549758E0E50"
echo ""

sudo -u shussain /opt/stibo/step/spot --package=/home/stibosw --target=$PREFIX,$VERSION --insecure=E9950549758E0E50

echo ""
echo ""

echo "Applying recipe..."
echo "sudo -u stibosw /opt/stibo/step/spot --apply=$PREFIX-$VERSION.spr --insecure=E9950549758E0E50"

sudo -u stibosw /opt/stibo/step/spot --apply=$PREFIX-$VERSION.spr --insecure=E9950549758E0E50

echo ""
echo ""

echo "deploy-dgl-extension.sh is done"
4 changes: 3 additions & 1 deletion src/main/groovy/job_glv_build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ for (serviceConfig in servicesConfig) {
wrappers { //colorizeOutput()
}
}

}

def serviceMasterBuild = job(masterBuildAndTest) {
Expand Down Expand Up @@ -166,8 +166,10 @@ for (serviceConfig in servicesConfig) {
useWrapper(true)
makeExecutable(true)
}

}


publishers {

def jobToTrigger = hasSonar ? masterBuildSonar : masterBuildPublish
Expand Down
99 changes: 99 additions & 0 deletions src/main/groovy/job_glvdeployment.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@


def commonDeploySwitches = '-Papp_name=${APP_NAME} -Papp_memory=${APP_MEMORY} -Ptarget_env=${TARGET_ENVIRONMENT} -Partifact_id=${artifact_id} -PconfigServergitrepo=https://github.gapinc.com/GLV/glv-config.git'

def deploymentJobs = [
[
'title' : 'deploy-to-local-lfw',
'envs' : ['development', 'integration','configuration'],
'env_desc' : 'Deploy to TDEV PCF Space',
'artifactory_url': 'https://localhost:8082/artifactory/scmd-lfw',

]

]

for (deploymentJob in deploymentJobs) {
def deployJob = job(deploymentJob['title']) {
wrappers {
credentialsBinding {

usernamePassword('GITHUB_USERNAME', 'GITHUB_PASSWORD', '85766806-3cb8-474e-966b-9e6d00f27764')

usernamePassword('ARTIFACTORY_USERNAME', 'ARTIFACTORY_PASSWORD', 'jfrog-creds')



}
}
parameters {
textParam('artifact_id', '', 'Input valid artifactId for the service')
choiceParam('TARGET_ENVIRONMENT', deploymentJob['envs'], deploymentJob['env_desc'])
choiceParam('APP_MEMORY', [
'1024',
'512',
'2048',
'4096',
'8192'
], 'Select the Amount of Memory Needed for your Application')
choiceParam('APP_NAME',
[
'glv-lfw-listener',

],
'Select the Application')
}

scm {
git {
remote {
url('https://github.com/imran-ishaq/SCMD.git')
credentials('85766806-3cb8-474e-966b-9e6d00f27764')
}
branch("main")
}
}
steps {
gradle {
useWrapper(true)
makeExecutable(true)
tasks('deploy')
fromRootBuildScriptDir(true)
switches(deploymentJob['deploy_switches'])
}
sh './upload-war.sh' ${buildDir/libs}
}

logRotator {
numToKeep(10)
artifactNumToKeep(1)
}
}

}

listView('Preprod Deploy Job') {
columns {
status()
weather()
name()
lastSuccess()
lastFailure()
lastDuration()
buildButton()
}
jobs { name('deploy-to-pre-prod') }

listView('PROD Deploy Job') {
columns {
status()
weather()
name()
lastSuccess()
lastFailure()
lastDuration()
buildButton()
}
jobs { name('deploy-to-prod') }
}
}
4 changes: 4 additions & 0 deletions src/main/groovy/upload-war.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

sshpass -p "l@s)-(@R!12345" ssh [email protected] ./deploy-war.sh $JAR_NAME
echo "Exiting..."

0 comments on commit 34c64b2

Please sign in to comment.