diff --git a/Jenkinsfile b/Jenkinsfile index 2cb340f..cca94e4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { agent { - label 'java' + label 'maven' } options { @@ -11,12 +11,14 @@ pipeline { stages{ stage('Build & Test'){ steps{ - try { - container('java'){ + script{ + try { + container('java'){ + sh 'mvn clean package test' + } + } catch(e) { sh 'mvn clean package test' } - } catch(e) { - sh 'mvn clean package test' } } } @@ -32,4 +34,10 @@ pipeline { } } } + + post{ + always{ + junit 'target/surefire-reports/**/*.xml' + } + } } diff --git a/Jenkinsfile-input b/Jenkinsfile-input new file mode 100644 index 0000000..9dc927d --- /dev/null +++ b/Jenkinsfile-input @@ -0,0 +1,65 @@ +pipeline { + agent any + + stages{ + stage('simple'){ + steps{ + input message: 'Please input your name!', ok: 'Confirm', + parameters: [string(defaultValue: 'rick', + description: 'This should not be your real name.', name: 'name', trim: true)] + } + } + + stage('complex'){ + parallel { + stage('channel-1'){ + steps{ + input message: 'Please input your age!', ok: 'Confirm', + parameters: [string(defaultValue: '18', + description: 'Just a joke.', name: 'age', trim: true)] + } + } + stage('channel-2'){ + steps{ + input message: 'Please input your weight!', ok: 'Confirm', + parameters: [string(defaultValue: '50', + description: 'Just a joke.', name: 'weight', trim: true)] + } + } + } + } + + stage('use result'){ + parallel { + stage('one param'){ + steps{ + script{ + result = input message: 'Please input the git branch name!', ok: 'Confirm', + parameters: [string(defaultValue: 'master', + description: 'The branch name of git repo', name: 'branchName', trim: true)] + + git branch: result, url: 'https://github.com/devops-workspace/demo-junit' + } + } + } + + stage('multi-param'){ + steps{ + script{ + result = input message: 'Please input the git branch name with debug info!', ok: 'Confirm', + parameters: [string(defaultValue: 'master', + description: 'The branch name of git repo', name: 'branchName', trim: true), + string(defaultValue: 'debug info', + description: 'Output the debug info', name: 'debugInfo', trim: true)] + + git branch: result.branchName, url: 'https://github.com/devops-workspace/demo-junit' + echo result.debugInfo + } + } + } + + } + } + + } +}