您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

49 行
1.5 KiB

  1. pipeline {
  2. agent any
  3. stages {
  4. stage('检出') {
  5. steps {
  6. checkout([$class: 'GitSCM', branches: [[name: env.GIT_BUILD_REF]],
  7. userRemoteConfigs: [[url: env.GIT_REPO_URL, credentialsId: env.CREDENTIALS_ID]]])
  8. }
  9. }
  10. stage('构建') {
  11. steps {
  12. sh 'mvn -version'
  13. echo '构建中...'
  14. sh 'mvn clean install -Dmaven.test.skip=true'
  15. echo '构建完成.'
  16. script {
  17. def exists = fileExists 'README.md'
  18. if (!exists) {
  19. writeFile(file: 'README.md', text: 'Helloworld')
  20. }
  21. }
  22. archiveArtifacts(artifacts: 'README.md', fingerprint: true)
  23. }
  24. }
  25. stage('测试') {
  26. steps {
  27. echo '单元测试中...'
  28. echo '单元测试完成.'
  29. writeFile(file: 'TEST-demo.junit4.AppTest.xml', text: '''
  30. <testsuite name="demo.junit4.AppTest" time="0.053" tests="3" errors="0" skipped="0" failures="0">
  31. <properties>
  32. </properties>
  33. <testcase name="testApp" classname="demo.junit4.AppTest" time="0.003"/>
  34. <testcase name="test1" classname="demo.junit4.AppTest" time="0"/>
  35. <testcase name="test2" classname="demo.junit4.AppTest" time="0"/>
  36. </testsuite>
  37. ''')
  38. junit '*.xml'
  39. }
  40. }
  41. stage('部署') {
  42. steps {
  43. echo '部署中...'
  44. echo '部署完成'
  45. }
  46. }
  47. }
  48. }