Jenkinsfile 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. 1. added
  3. client_max_body_size 0;
  4. to avoid 413 error
  5. 2. npm install error internet problem, fake update 1
  6. */
  7. node {
  8. def app
  9. def registryAddress
  10. def registryCredential
  11. try {
  12. // environment {
  13. registryAddress = "https://registry.sidali.sixsenz.net"
  14. registryCredential = 'DockerRegistry-ID'
  15. // }
  16. stage('Checkout') {
  17. checkout scm
  18. }
  19. stage('Initialize'){
  20. def dockerHome = tool 'myDocker'
  21. env.PATH = "${dockerHome}/bin:${env.PATH}"
  22. }
  23. stage('Environment') {
  24. sh 'git --version'
  25. echo "Branch: master"
  26. sh 'docker -v'
  27. sh 'printenv'
  28. }
  29. stage('Test Build'){
  30. sh 'docker build -t ptb-fe:latest -f dockerfile .'
  31. }
  32. stage('Build Deploy '){
  33. // // now you are on slave labeled with 'label'
  34. // def workspace = WORKSPACE
  35. // // ${workspace} will now contain an absolute path to job workspace on slave
  36. // workspace = env.WORKSPACE
  37. // // ${workspace} will still contain an absolute path to job workspace on slave
  38. // // When using a GString at least later Jenkins versions could only handle the env.WORKSPACE variant:
  39. // echo "Current workspace is ${env.WORKSPACE}"
  40. // // the current Jenkins instances will support the short syntax, too:
  41. // echo "Current workspace is $WORKSPACE"
  42. docker.withTool("myDocker"){
  43. docker.withRegistry(registryAddress, registryCredential) {
  44. def dockerImage = docker.build("ptb-fe:${env.BUILD_ID}")
  45. /* Push the container to the custom Registry */
  46. dockerImage.push()
  47. dockerImage.push('latest')
  48. }
  49. }
  50. }
  51. }
  52. catch (err) {
  53. throw err
  54. }
  55. }