call library functions in jenkinsfile
This commit is contained in:
17
Jenkinsfile
vendored
17
Jenkinsfile
vendored
@@ -1,7 +1,10 @@
|
|||||||
|
#!/usr/bin/env groovy
|
||||||
|
|
||||||
|
@Library('jenkins-shared-library')
|
||||||
def gv
|
def gv
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent none
|
||||||
tools {
|
tools {
|
||||||
maven 'Maven'
|
maven 'Maven'
|
||||||
}
|
}
|
||||||
@@ -15,16 +18,12 @@ pipeline {
|
|||||||
}
|
}
|
||||||
stage("build jar") {
|
stage("build jar") {
|
||||||
steps {
|
steps {
|
||||||
script {
|
buildJar()
|
||||||
gv.buildJar()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage("build image") {
|
stage("build image") {
|
||||||
steps {
|
steps {
|
||||||
script {
|
buildImage()
|
||||||
gv.buildImage()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage("deploy") {
|
stage("deploy") {
|
||||||
@@ -34,5 +33,5 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,5 @@
|
|||||||
def buildJar() {
|
|
||||||
echo "building the application..."
|
|
||||||
sh 'mvn package'
|
|
||||||
}
|
|
||||||
|
|
||||||
def buildImage() {
|
|
||||||
echo "building the docker image..."
|
|
||||||
withCredentials([usernamePassword(credentialsId: 'docker-hub-repo', passwordVariable: 'PASS', usernameVariable: 'USER')]) {
|
|
||||||
sh 'docker build -t nanajanashia/demo-app:jma-2.0 .'
|
|
||||||
sh "echo $PASS | docker login -u $USER --password-stdin"
|
|
||||||
sh 'docker push nanajanashia/demo-app:jma-2.0'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def deployApp() {
|
def deployApp() {
|
||||||
echo 'deploying the application...'
|
echo 'deploying the application...'
|
||||||
}
|
}
|
||||||
|
|
||||||
return this
|
return this
|
||||||
|
|||||||
Reference in New Issue
Block a user