Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jenkins-practice
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad Tehami
jenkins-practice
Commits
31202d4b
Commit
31202d4b
authored
Feb 12, 2020
by
Muhammad Tehami
💡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Jenkins files added
parent
061ed461
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
391 additions
and
0 deletions
+391
-0
artifactory.txt
jenkins-files/artifactory.txt
+89
-0
compile-test-artifactory-docker.txt
jenkins-files/compile-test-artifactory-docker.txt
+94
-0
java-project-pipeline.txt
jenkins-files/java-project-pipeline.txt
+42
-0
java-project-pipeline.txt~
jenkins-files/java-project-pipeline.txt~
+0
-0
shared-lib-pipeline.txt
jenkins-files/shared-lib-pipeline.txt
+18
-0
shared-lib-pipeline.txt~
jenkins-files/shared-lib-pipeline.txt~
+0
-0
shared-lib-with-stages.txt
jenkins-files/shared-lib-with-stages.txt
+39
-0
solitaire-pipeline.txt
jenkins-files/solitaire-pipeline.txt
+63
-0
solitaire-pipeline.txt~
jenkins-files/solitaire-pipeline.txt~
+0
-0
test-petclinic.txt
jenkins-files/test-petclinic.txt
+46
-0
test-petclinic.txt~
jenkins-files/test-petclinic.txt~
+0
-0
No files found.
jenkins-files/artifactory.txt
0 → 100644
View file @
31202d4b
// Declarative Pipeline Syntax
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git 'https://gitlab.mynisum.com/mtehami/jenkins-practice.git'
}
}
stage('Compile, Test, Package, Archive') {
steps {
dir('java-project') {
sh 'mvn clean package test verify'
archiveArtifacts 'target/java-project-1.0-SNAPSHOT.jar'
}
}
}
stage('Upload Artifact') {
steps {
rtServer (
id: 'Artifactory-1',
url: 'http://localhost:8081/artifactory',
// If you're using username and password:
username: 'admin',
password: '123456seven',
// 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
)
rtUpload (
serverId: 'Artifactory-1',
spec: '''{
"files": [
{
"pattern": "java-project/target/java-project-1.0-SNAPSHOT.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
)
}
}
}
}
// Scripted Pipeline Syntax
// node {
// stage 'checkout'
// try {
// git 'https://gitlab.mynisum.com/mtehami/jenkins-practice.git'
// def project_path = "java-project"
// dir(project_path) {
// stage 'clean, compile'
// sh 'mvn clean compile'
// stage 'test'
// sh 'mvn test'
// stage 'package, archive'
// sh 'mvn package verify'
// archiveArtifacts 'target/java-project-1.0-SNAPSHOT.jar'
// }
// stage 'Uploading Artifact'
// def server = Artifactory.server 'artifactory'
// def uploadSpec = """{
// "files": [
// {
// "pattern": "java-project/target/java-project-1.0-SNAPSHOT.jar",
// "target": "libs-snapshot-local"
// }
// ]
// }"""
// server.upload spec: uploadSpec
// // server.publishBuildInfo buildInfo
// } catch(err) {
// currentBuild.result = 'FAILURE'
// }
// }
jenkins-files/compile-test-artifactory-docker.txt
0 → 100644
View file @
31202d4b
pipeline {
agent any
stages {
stage('Checkout Source Code') {
steps {
git 'https://gitlab.mynisum.com/mtehami/jenkins-practice.git'
}
}
stage('Compile, Test, Package') {
steps {
dir('spring-petclinic') {
sh 'mvn clean package test'
}
}
}
stage('Archiving') {
steps {
dir('spring-petclinic') {
sh 'mvn package verify'
archiveArtifacts 'target/*.jar'
step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/TEST*.xml'])
}
}
}
stage('Publishing Code Coverage Reports') {
steps {
publishHTML(
target: [
allowMissing: true,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'spring-petclinic/target/site/jacoco',
reportFiles: 'index.html',
reportName: 'Code Coverage Report',
reportTitles: 'Code Coverage Report'
]
)
}
}
stage('Uploading Artifact') {
steps {
rtServer (
id: 'Artifactory-1',
url: 'http://localhost:8081/artifactory',
// If you're using username and password:
username: 'admin',
password: '123456seven',
// 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
)
rtUpload (
serverId: 'Artifactory-1',
spec: '''{
"files": [
{
"pattern": "spring-petclinic/target/spring-petclinic-2.2.0.BUILD-SNAPSHOT.jar",
"target": "libs-snapshot-local"
}
]
}''',
// Optional - Associate the uploaded files with the following custom build name and build number,
// as build artifacts.
// 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 and Push to Docker Hub') {
steps{
dir('spring-petclinic') {
sh "docker build -t tehami/petclinic:build-${env.BUILD_NUMBER} ."
sh "docker push tehami/petclinic:build-${env.BUILD_NUMBER}"
}
}
}
stage('Deploy to GC Cluster') {
steps {
script {
// String manifestFile = new File( 'Manifest.yml' ).getText( 'UTF-8' )
// manifestFile = contents.replaceAll( 'build-number', env.BUILD_NUMBER )
sh "kubectl apply -f spring-petclinic/Manifest.yml"
}
}
}
}
}
jenkins-files/java-project-pipeline.txt
0 → 100644
View file @
31202d4b
node {
notify("Start")
stage 'checkout'
try {
git 'https://gitlab.mynisum.com/mtehami/jenkins-practice.git'
def project_path = "java-project"
dir(project_path) {
stage 'clean, compile'
sh 'mvn clean compile'
stage 'test'
sh 'mvn test'
stage 'package, archive'
sh 'mvn package verify'
archiveArtifacts 'target/*.jar'
}
notify("Successful")
} catch(err) {
notify("Error")
currentBuild.result = 'FAILURE'
}
publishHTML(
target: [
allowMissing: true,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'java-project/target/site/jacoco',
reportFiles: 'index.html',
reportName: 'HTML Report',
reportTitles: 'Code Coverage Report'
]
)
}
def notify(status) {
emailext(
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>""",
subject: "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
to: 'test@mailhog.com'
)
}
jenkins-files/java-project-pipeline.txt~
0 → 100644
View file @
31202d4b
jenkins-files/shared-lib-pipeline.txt
0 → 100644
View file @
31202d4b
@Library('jenkins-pipeline-shared-lib-sample')_
// stage('Print Build Info') {
// printBuildinfo {
// name = "Sample Name"
// }
// hello.hello()
// }
stage('Disable balancer') {
disableBalancerUtils()
} stage('Deploy') {
deploy()
} stage('Enable balancer') {
enableBalancerUtils()
} stage('Check Status') {
checkStatus()
}
jenkins-files/shared-lib-pipeline.txt~
0 → 100644
View file @
31202d4b
jenkins-files/shared-lib-with-stages.txt
0 → 100644
View file @
31202d4b
@Library('jenkins-pipeline-shared-lib-sample')_
pipeline {
agent any
stages {
stage('Print Build Info') {
steps {
script {
printBuildinfo { name = "Sample Name" }
}
}
}
stage('Greeting') {
steps{
// hello()
echo "Greetings!"
}
}
stage('Disable balancer') {
steps{
disableBalancerUtils()
}
}
stage('Deploy') {
steps{
deploy()
}
}
stage('Enable balancer') {
steps{
enableBalancerUtils()
}
}
stage('Check Status') {
steps{
checkStatus()
}
}
}
}
jenkins-files/solitaire-pipeline.txt
0 → 100644
View file @
31202d4b
stage 'CI'
node {
git 'https://gitlab.mynisum.com/mtehami/jenkins-practice.git'
dir('solitaire-javascript') {
// 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: 'solitaire-javascript/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'
dir('solitaire-javascript') {
// on windows use: bat "npm run test-single-run -- --browsers ${browser}"
sh "npm run test-single-run -- --browsers ${browser}"
}
sh 'ls'
step([$class: 'JUnitResultArchiver',
testResults: 'test-results/**/test-results.xml'])
}
}
stage name: 'Deploy to staging', concurrency: 1
input 'Deploy to staging?'
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'
}
jenkins-files/solitaire-pipeline.txt~
0 → 100644
View file @
31202d4b
jenkins-files/test-petclinic.txt
0 → 100644
View file @
31202d4b
def project_path = "spring-petclinic"
node {
// notify("Start")
stage 'checkout'
try {
git 'https://gitlab.mynisum.com/mtehami/jenkins-practice.git'
dir(project_path) {
stage 'clean, compile'
sh 'mvn clean compile'
stage 'test'
sh 'mvn test'
stage 'package, archive'
}
// notify("Successful")
} catch(err) {
// notify("Error")
println "Error: $err"
currentBuild.result = 'FAILURE'
}
dir(project_path) {
sh 'mvn package verify'
archiveArtifacts 'target/*.jar'
step([$class: 'JUnitResultArchiver', testResults: 'target/surefire-reports/TEST*.xml'])
}
publishHTML(
target: [
allowMissing: true,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: 'spring-petclinic/target/site/jacoco',
reportFiles: 'index.html',
reportName: 'Code Coverage Report',
reportTitles: 'Code Coverage Report'
]
)
}
def notify(status) {
emailext(
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>""",
subject: "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
to: 'test@mailhog.com'
)
}
jenkins-files/test-petclinic.txt~
0 → 100644
View file @
31202d4b
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment