Skip to content

Commit

Permalink
Merge branch 'kel/newJenkis' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
lausdahl committed Oct 3, 2017
2 parents 4616885 + 9c08dea commit 3730421
Showing 1 changed file with 139 additions and 74 deletions.
213 changes: 139 additions & 74 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,99 +1,164 @@

def userInputAcceptRelease = false

node{
// Only keep one build
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '5']]])

// Mark the code checkout 'stage'....
stage ('Checkout')
{
checkout scm
sh 'git submodule update --init --remote'
}
}


node {
try
{

// Only keep one build
properties([[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '5']]])

// Mark the code checkout 'stage'....
stage ('Checkout')
{
checkout scm
sh 'git submodule update --init --remote'
}

stage ('Clean'){
withMaven(mavenLocalRepo: '.repository', mavenSettingsFilePath: "${env.MVN_SETTINGS_PATH}") {

// Run the maven build
sh "mvn clean install -U -PWith-IDE -Pcodesigning"
}}

stage ('Build'){
withMaven(mavenLocalRepo: '.repository', mavenSettingsFilePath: "${env.MVN_SETTINGS_PATH}") {

// Run the maven build
sh "mvn install -Pall-platforms -PWith-IDE -Pcodesigning"
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
step([$class: 'JacocoPublisher'])
step([$class: 'TasksPublisher', canComputeNew: false, defaultEncoding: '', excludePattern: '', healthy: '', high: 'FIXME', ignoreCase: true, low: '', normal: 'TODO', pattern: '', unHealthy: ''])
}}

stage ('Integration test'){

if (env.BRANCH_NAME == 'release') {

try {
timeout(time: 15, unit: 'MINUTES') { // change to a convenient timeout for you
userInput = input(
id: 'ReleaseMaster', message: 'Run perform release on the release branch?', parameters: [
[$class: 'BooleanParameterDefinition', defaultValue: true, description: '', name: 'Please confirm you agree with this']
])
}
} catch(err) { // timeout reached or input false
// def user = err.getCauses()[0].getUser()
//if('SYSTEM' == user.toString()) { // SYSTEM means timeout.
// didTimeout = true
//} else {
// userInput = false
//echo "Aborted by: [${user}]"
// }
userInputAcceptRelease = true
}

if(userInputAcceptRelease)
{
sh "echo build..."
sh "wget -q https://raw.githubusercontent.com/overturetool/overture-release-scripts/master/perform-release.sh -O perform-release.sh"
sh "chmod +x perform-release.sh"
sh "wget -q https://raw.githubusercontent.com/overturetool/overture-release-scripts/master/git-set-private-key.sh -O git-set-private-key.sh"
sh "chmod +x git-set-private-key.sh"
sh "git checkout development"
sh "batchmode=release ./perform-release.sh ${env.MVN_SETTINGS_PATH}"


sh "echo Detecting current version"

version = sh "mvn -f target/checkout -q -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/"

version = sh (script: "mvn -f target/checkout -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/ | grep -v '\\[' | grep -v -e '^\$'" , returnStdout:true).trim()

sh "echo Version K${version}K"

sh "cp target/checkout/core/fmu-import-export/target/fmu-import-export-${version}-jar-with-dependencies.jar target/checkout/ide/repository/target/repository/fmu-import-export.jar"

sh '''#/bin/bash
cd target/checkout/ide/repository/target/repository
zip -r ../p2.zip .
mv ../p2.zip .
'''


}
}else
{

stage ('Clean'){
withMaven(mavenLocalRepo: '.repository', mavenSettingsFilePath: "${env.MVN_SETTINGS_PATH}") {

// Run the maven build
sh "mvn clean install -U -PWith-IDE -Pcodesigning"
}}

stage ('Build'){
withMaven(mavenLocalRepo: '.repository', mavenSettingsFilePath: "${env.MVN_SETTINGS_PATH}") {

// Run the maven build
sh "mvn install -Pall-platforms -PWith-IDE -Pcodesigning"
step([$class: 'ArtifactArchiver', artifacts: '**/target/*.jar', fingerprint: true])
step([$class: 'JUnitResultArchiver', testResults: '**/target/surefire-reports/TEST-*.xml'])
step([$class: 'JacocoPublisher'])
step([$class: 'TasksPublisher', canComputeNew: false, defaultEncoding: '', excludePattern: '', healthy: '', high: 'FIXME', ignoreCase: true, low: '', normal: 'TODO', pattern: '', unHealthy: ''])
}}

stage ('Integration test'){

sh "cd testing && ./integration-test.sh"
sh "cd testing && ./integration-test.sh"

}
}

stage ('FMI Compliance Test'){
stage ('FMI Compliance Test'){

sh "cd testing && ./validate.sh"
sh "cd testing && ./validate.sh"

}
}

stage ('Copy CLI to repo'){
stage ('Copy CLI to repo'){

sh "echo Detecting current version"
sh "echo Detecting current version"

version = sh "mvn -q -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/"
version = sh "mvn -q -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/"

version = sh (script: "mvn -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/ | grep -v '\\[' | grep -v -e '^\$'" , returnStdout:true).trim()
version = sh (script: "mvn -s ${env.MVN_SETTINGS_PATH} -N org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -DDmaven.repo.local=.repository/ | grep -v '\\[' | grep -v -e '^\$'" , returnStdout:true).trim()

sh "echo Version K${version}K"
sh "echo Version K${version}K"

sh "cp core/fmu-import-export/target/fmu-import-export-${version}-jar-with-dependencies.jar ide/repository/target/repository/fmu-import-export.jar"
sh "cp core/fmu-import-export/target/fmu-import-export-${version}-jar-with-dependencies.jar ide/repository/target/repository/fmu-import-export.jar"

}
}

stage ('Publish Artifactory'){
stage ('Publish Artifactory'){

if (env.BRANCH_NAME == 'development') {

def server = Artifactory.server "-225816141@1439286524510"
def buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true
//buildInfo.env.filter.addExclude("org/destecs/ide/**")
def rtMaven = Artifactory.newMavenBuild()
rtMaven.tool = "Maven 3.3.3" // Tool name from Jenkins configuration
rtMaven.opts = "-Xmx1024m -XX:MaxPermSize=256M"
rtMaven.deployer releaseRepo:'overture-fmu', snapshotRepo:'overture-fmu', server: server

rtMaven.run pom: 'pom.xml', goals: 'install', buildInfo: buildInfo
if (env.BRANCH_NAME == 'development') {

//get rid of old snapshots only keep then for a short amount of time
buildInfo.retention maxBuilds: 5, maxDays: 7, deleteBuildArtifacts: true

// Publish build info.
server.publishBuildInfo buildInfo
}
}
def server = Artifactory.server "-844406945@1404457436085"
def buildInfo = Artifactory.newBuildInfo()
buildInfo.env.capture = true

def rtMaven = Artifactory.newMavenBuild()
rtMaven.tool = "Maven 3.1.1" // Tool name from Jenkins configuration
rtMaven.opts = "-Xmx1024m -XX:MaxPermSize=256M"
rtMaven.deployer releaseRepo:'overture-fmu', snapshotRepo:'overture-fmu', server: server

rtMaven.run pom: 'pom.xml', goals: 'install', buildInfo: buildInfo

//get rid of old snapshots only keep then for a short amount of time
buildInfo.retention maxBuilds: 5, maxDays: 7, deleteBuildArtifacts: true

stage ('Deploy'){
if (env.BRANCH_NAME == 'development') {

sh "echo branch is now ${env.BRANCH_NAME}"
// Publish build info.
server.publishBuildInfo buildInfo
}
}

}

stage ('Deploy'){
def deployBranchName = env.BRANCH_NAME
if (env.BRANCH_NAME == 'development' || env.BRANCH_NAME == 'release') {
if(env.BRANCH_NAME == 'release')
{
deployBranchName = "master"
}

sh "echo branch is now ${env.BRANCH_NAME}"

DEST = sh script: "echo /home/jenkins/web/into-cps/vdm-tool-wrapper/${env.BRANCH_NAME}/Build-${BUILD_NUMBER}_`date +%Y-%m-%d_%H-%M`", returnStdout:true
REMOTE = "[email protected]"

sh "echo The remote dir will be: ${DEST}"
sh "ssh ${REMOTE} mkdir -p ${DEST}"
sh "scp -r ide/repository/target/repository/* ${REMOTE}:${DEST}"
sh "ssh ${REMOTE} /home/jenkins/update-latest.sh web/into-cps/vdm-tool-wrapper/${env.BRANCH_NAME}"
}
}
DEST = sh script: "echo /home/jenkins/web/into-cps/vdm-tool-wrapper/${deployBranchName}/Build-${BUILD_NUMBER}_`date +%Y-%m-%d_%H-%M`", returnStdout:true
REMOTE = "[email protected]"

sh "echo The remote dir will be: ${DEST}"
sh "ssh ${REMOTE} mkdir -p ${DEST}"
sh "scp -r ide/repository/target/repository/* ${REMOTE}:${DEST}"
sh "ssh ${REMOTE} /home/jenkins/update-latest.sh web/into-cps/vdm-tool-wrapper/${deployBranchName}"
}
}


} catch (any) {
Expand Down

0 comments on commit 3730421

Please sign in to comment.