11#! groovy
22
3- def checkoutCode () {
4- stage ' checkout'
5- checkout scm : [$class : ' GitSCM' , branches : [[name : ' */master' ]], userRemoteConfigs : [[url : ' https://github.com/codesqueak/jackson-json-crypto.git' ]]]
6- }
7-
8- def build () {
9- stage ' build'
10- sh ' ./gradlew clean build -x test'
11- }
12-
13- def test () {
14- stage ' test'
15- sh ' ./gradlew test'
16- }
17-
18- def junitreport () {
19- stage ' JUnit report'
20- step([$class : ' JUnitResultArchiver' , testResults : ' build/test-results/test/TEST-*.xml' ])
21- }
22-
23- def findbugsreport () {
24- stage ' Findbugs report'
25- step([$class : ' FindBugsPublisher' , pattern : ' build/reports/findbugs/main.xml' ])
26- }
27-
28- def jacocoreport () {
29- stage ' Jacoco report'
30- step([$class : ' JacocoPublisher' , execPattern : ' build/jacoco/jacocoTest.exec' , pattern : ' build/jacoco/classpathdumps/net/codingrodent/**/*.class' ])
31- }
32-
33-
34- stage ' execute Z80 build'
35-
36- node {
37- checkoutCode()
38- build()
39- test()
40- junitreport()
41- findbugsreport()
42- jacocoreport()
43- }
3+ pipeline {
4+ agent any
5+ stages {
6+ stage(' Checkout' ) {
7+ steps { // Checking out the repo
8+ checkout scm : [$class : ' GitSCM' , branches : [[name : ' */master' ]], userRemoteConfigs : [[url : ' https://github.com/codesqueak/jackson-json-crypto.git' ]]]
9+ echo env. GIT_BRANCH
10+ sh ' echo $GIT_BRANCH'
11+ }
12+ }
13+
14+
15+
16+ stage(' Build' ) {
17+ steps { // Build using jenkins
18+ sh ' ./gradlew clean build test'
19+ }
20+ }
21+
22+ stage(' Jar' ) {
23+ steps { // Make a jar file
24+ sh ' ./gradlew jar'
25+ }
26+ }
27+
28+ stage(' branch' ) {
29+ steps { // branch check
30+ echo env. GIT_BRANCH
31+ sh ' echo $GIT_BRANCH'
32+ }
33+ }
34+
35+ stage (' develop' ) {
36+ when {
37+ expression { env. GIT_BRANCH == ' origin/develop' }
38+ }
39+ steps {
40+ echo " Hello origin/develop"
41+ }
42+ }
43+
44+ stage (' release' ) {
45+ when {
46+ expression { env. GIT_BRANCH == ' origin/release' }
47+ }
48+ steps {
49+ echo " Hello origin/release"
50+ }
51+ }
52+
53+ stage (' master' ) {
54+ when {
55+ expression { env. GIT_BRANCH == ' origin/master' }
56+ }
57+ steps {
58+ echo " Hello origin/master"
59+ }
60+ }
61+
62+
63+ }
64+ post {
65+ success {
66+ junit testResults : ' **/test-results/test/TEST-*.xml'
67+ jacoco execPattern : ' **/jacoco/jacocoTest.exec'
68+ recordIssues enabledForFailure : true , tool : spotBugs(pattern : ' **/reports/spotbugs/*.xml' )
69+ }
70+ }
71+ }
0 commit comments