Commit 18531cb8 authored by kmohiuddin's avatar kmohiuddin

Pipeline Commit Initiated

parents
@Library('shared_library_clone_example')_
pipeline {
agent any
stages {
stage('Checkout') {
steps{
git 'https://gitlab.mynisum.com/kmohiuddin/spring_petclinic_clone.git'
}
}
stage('Clean Verify') {
steps{
sh 'mvn clean verify'
}
}
stage('Configure Artifactory') {
steps {
rtServer (
id: 'Artifactory-1',
url: 'http://localhost:8081/artifactory',
// If you're using username and password:
username: 'admin',
password: 'password',
// If you're using Credentials ID:
// credentialsId: 'ccrreeddeennttiiaall'
// If Jenkins is configured to use an http proxy, you can bypass the proxy when using this Artifactory server:
// bypassProxy: true,
// Configure the connection timeout (in seconds).
// The default value (if not configured) is 300 seconds:
timeout: 300
)
}
}
stage('Uploading Artifact') {
steps {
rtUpload (
serverId: 'Artifactory-1',
spec: '''{
"files": [
{
"pattern": "target/*.jar",
"target": "libs-snapshot-local"
}
]
}''',
// Optional - Associate the downloaded files with the following custom build name and build number,
// as build dependencies.
// If not set, the files will be associated with the default build name and build number (i.e the
// the Jenkins job name and number).
buildName: env.JOB_NAME,
buildNumber: env.BUILD_NUMBER
)
}
}
stage('Creating Docker Image') {
steps {
sh "docker build -t khawajaibrahim/pet_clinic:build-${env.BUILD_NUMBER} ."
sh "docker push khawajaibrahim/pet_clinic:build-${env.BUILD_NUMBER}"
}
}
stage('Deploy to kubernetes') {
steps {
sh "kubectl create -f deployment.yaml"
}
}
}
}
node{
stage 'checkout'
git 'https://github.com/mkyong/maven-examples.git'
def project_path="java-project"
dir(project_path){
stage 'Cleaning, Compiling, Testing, Packaging'
sh 'mvn clean package'
stage 'Archiving'
archiveArtifacts 'target/*.jar'
}
}
node{
def flag = 0;
try{
//notify('Started Build')
stage 'checkout'
git 'https://github.com/spring-projects/spring-petclinic.git'
def project_path=""
dir(project_path){
stage 'Cleaning, Compiling, Testing, Packaging'
sh 'mvn clean verify'
stage 'Archiving'
archiveArtifacts 'target/*.jar'
stage 'Generate Test Reports'
// publishHTML(target: [allowMissing: true, alwaysLinkToLastBuild: false,
// keepAll: true, reportDir: 'target/site/jacoco',
// reportFiles: 'index.html', reportName: 'Code Coverage Report',
// reportTitles: ''])
// step([$class: 'JUnitResultArchiver',
// testResults: 'target/surefire-reports/TEST-*.xml'])
}
//notify('Build Ended Successfully')
stage 'configure server'
def server = Artifactory.newServer url: 'http://localhost:8081/artifactory',
username: 'admin', password: 'password'
// If Jenkins is configured to use an http proxy, you can bypass the proxy when using this Artifactory server:
server.bypassProxy = true
// If you're using username and password:
//server.username = 'new-user-name'
//server.password = 'new-password'
// If you're using Credentials ID:
//server.credentialsId = 'ccrreeddeennttiiaall'
// Configure the connection timeout (in seconds).
// The default value (if not configured) is 300 seconds:
server.connection.timeout = 300
stage 'upload artifact to server'
def uploadSpec = """{
"files": [
{
"pattern": "target/*.jar",
"target": "libs-snapshot-local"
}
]
}"""
server.upload spec: uploadSpec
}
catch(err){
flag = 1;
//notify('Error ${err}')
currentBuild.result('FAILURE');
}
}
def notify(status){
emailext (
to: "ibrahim@gmail.com",
subject: "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
)
}
@Library('shared_library_clone_example')_
pipeline {
agent any
stages {
stage('Print Build Info') {
steps{
//sh 'echo hello'
script {
printBuildinfo {
name = "Sample Name"
}
}
}
}
stage('Greeting') {
steps{
hello()
}
}
stage('Disable balancer') {
steps{
disableBalancerUtils()
}
}
stage('Deploy') {
steps{
deploy()
}
}
stage('Enable balancer') {
steps{
enableBalancerUtils()
}
}
stage('Check Status') {
steps{
checkStatus()
}
}
}
}
stage 'CI'
node {
git branch: 'jenkins2-course',
url: 'https://github.com/g0t4/solitaire-systemjs-course'
// pull dependencies from npm
// on windows use: bat 'npm install'
sh 'npm install'
// stash code & dependencies to expedite subsequent testing
// and ensure same code & dependencies are used throughout the pipeline
// stash is a temporary archive
stash name: 'everything',
excludes: 'test-results/**',
includes: '**'
// test with PhantomJS for "fast" "generic" results
// on windows use: bat 'npm run test-single-run -- --browsers PhantomJS'
sh 'npm run test-single-run -- --browsers PhantomJS'
// archive karma test results (karma is configured to export junit xml files)
step([$class: 'JUnitResultArchiver',
testResults: 'test-results/**/test-results.xml'])
}
stage 'Browser Testing'
parallel chrome: {
runTests("Chrome")
}, firefox: {
runTests("Firefox")
}
def runTests(browser) {
node {
// on windows use: bat 'del /S /Q *'
sh 'rm -rf *'
unstash 'everything'
// on windows use: bat "npm run test-single-run -- --browsers ${browser}"
sh "npm run test-single-run -- --browsers ${browser}"
echo "Browser: $browser"
sh 'ls'
step([$class: 'JUnitResultArchiver',
testResults: 'test-results/**/test-results.xml'])
}
}
node('linux_agent1') {
sh 'ls'
sh 'rm -rf *'
unstash 'everything'
sh 'ls'
}
stage "Ready to Deploy"
input "Deploy to staging?"
stage name: "Deploy to staging", concurrency: 1
node{
// write build number to index page so we can see this update
// on windows use: bat "echo '<h1>${env.BUILD_DISPLAY_NAME}</h1>' >> app/index.html"
sh "echo '<h1>${env.BUILD_DISPLAY_NAME}</h1>' >> app/index.html"
// deploy to a docker container mapped to port 3000
// on windows use: bat 'docker-compose up -d --build'
sh 'docker-compose up -d --build'
notify 'Solitaire Deployed!'
}
def notify(status){
emailext (
to: "ibrahim@gmail.com",
subject: "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
)
}
node{
try{
notify('Started Build')
stage 'checkout'
git 'https://gitlab.mynisum.com/kmohiuddin/java_test_project_for_jenkins.git'
def project_path="java-project"
dir(project_path){
stage 'Cleaning, Compiling, Testing, Packaging'
sh 'mvn clean package'
stage 'Archiving'
archiveArtifacts 'target/*.jar'
}
notify('Build Ended Successfully')
}
catch(err){
notify('Error ${err}')
currentBuild.result('FAILURE');
}
}
def notify(status){
emailext (
to: "ibrahim@gmail.com",
subject: "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at <a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a></p>""",
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment