Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env groovy
- // This will extract the branch name based on Git Flow to be used
- // for docker image tags and environment deployments
- String safeBranchName = 'develop'
- String openshiftCredential='****'
- String openshiftAppName='logviewer' // DO NOT CHANGE used for both docker repo and openshift application name 1:1
- String dockerCredential='****'
- String dockerOrg='****'
- String jenkinsBuildEmailTo='****'
- // *** DO NOT MODIFY ***
- String dockerPath="https://docker.****.com/$dockerOrg/$openshiftAppName:latest" // ORG AND REPO MUST EXIST
- // *** DO NOT MODIFY ***
- // The Jenkins Global Pipeline Library that is being used is: https://github.****.com/jenkins-pipelines/global-pipeline-library
- @Library("com.****.jenkins.pipeline.library@master") _
- pipeline {
- agent {
- label 'docker-maven-slave' // Jenkins build agent/slave, example: docker-oc-slave
- }
- stages {
- stage ('Create docker repository if not exists') {
- steps {
- glDockerRepoCreate dockerCredentialsId:"****",
- dockerHost:"docker.****.com",
- namespace:"****",
- repository:"****"
- }
- }
- stage ('Build and Push Docker Image') {
- steps {
- script {
- docker.withTool('docker-1.11.2') {
- docker.withRegistry('https://docker.****.com', "****") {
- newImage = docker.build("****/logviewer:$safeBranchName")
- newImage.push("latest")
- }
- }
- }
- }
- }
- }
- post {
- always {
- echo 'This will always run'
- }
- success {
- echo 'This will run only if successful'
- }
- failure {
- echo 'This will run only if failed'
- emailext body: "Build URL: ${BUILD_URL}",
- subject: "$currentBuild.currentResult-$JOB_NAME",
- to: "$jenkinsBuildEmailTo"
- }
- unstable {
- echo 'This will run only if the run was marked as unstable'
- }
- changed {
- echo 'This will run only if the state of the Pipeline has changed'
- echo 'For example, if the Pipeline was previously failing but is now successful'
- }
- }
- }
Add Comment
Please, Sign In to add comment