-
Notifications
You must be signed in to change notification settings - Fork 4
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 #2 from kevangel79/feature/DEVOPS-91-Add-jenkinsfile
DEVOPS-91 Add Jenkinsfile
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
pipeline { | ||
agent any | ||
options { | ||
checkoutToSubdirectory('nagios-plugins-eudat-b2share') | ||
} | ||
environment { | ||
PROJECT_DIR="nagios-plugins-eudat-b2share" | ||
GIT_COMMIT=sh(script: "cd ${WORKSPACE}/$PROJECT_DIR && git log -1 --format=\"%H\"",returnStdout: true).trim() | ||
GIT_COMMIT_HASH=sh(script: "cd ${WORKSPACE}/$PROJECT_DIR && git log -1 --format=\"%H\" | cut -c1-7",returnStdout: true).trim() | ||
GIT_COMMIT_DATE=sh(script: "date -d \"\$(cd ${WORKSPACE}/$PROJECT_DIR && git show -s --format=%ci ${GIT_COMMIT_HASH})\" \"+%Y%m%d%H%M%S\"",returnStdout: true).trim() | ||
|
||
} | ||
stages { | ||
stage ('Build'){ | ||
parallel { | ||
stage ('Build Centos 6') { | ||
agent { | ||
docker { | ||
image 'argo.registry:5000/epel-6-ams' | ||
args '-u jenkins:jenkins' | ||
} | ||
} | ||
steps { | ||
echo 'Building Rpm...' | ||
withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'jenkins-rpm-repo', usernameVariable: 'REPOUSER', \ | ||
keyFileVariable: 'REPOKEY')]) { | ||
sh "/home/jenkins/build-rpm.sh -w ${WORKSPACE} -b ${BRANCH_NAME} -d centos6 -p ${PROJECT_DIR} -s ${REPOKEY}" | ||
} | ||
archiveArtifacts artifacts: '**/*.rpm', fingerprint: true | ||
} | ||
} | ||
stage ('Build Centos 7') { | ||
agent { | ||
docker { | ||
image 'argo.registry:5000/epel-7-ams' | ||
args '-u jenkins:jenkins' | ||
} | ||
} | ||
steps { | ||
echo 'Building Rpm...' | ||
withCredentials(bindings: [sshUserPrivateKey(credentialsId: 'jenkins-rpm-repo', usernameVariable: 'REPOUSER', \ | ||
keyFileVariable: 'REPOKEY')]) { | ||
sh "/home/jenkins/build-rpm.sh -w ${WORKSPACE} -b ${BRANCH_NAME} -d centos7 -p ${PROJECT_DIR} -s ${REPOKEY}" | ||
} | ||
archiveArtifacts artifacts: '**/*.rpm', fingerprint: true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
post { | ||
always { | ||
cleanWs() | ||
} | ||
success { | ||
script{ | ||
if ( env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'devel' ) { | ||
slackSend( message: ":rocket: New version for <$BUILD_URL|$PROJECT_DIR>:$BRANCH_NAME Job: $JOB_NAME !") | ||
} | ||
} | ||
} | ||
failure { | ||
script{ | ||
if ( env.BRANCH_NAME == 'master' || env.BRANCH_NAME == 'devel' ) { | ||
slackSend( message: ":rain_cloud: Build Failed for <$BUILD_URL|$PROJECT_DIR>:$BRANCH_NAME Job: $JOB_NAME") | ||
} | ||
} | ||
} | ||
} | ||
} |