You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Jenkinsfile 3.5KB

  1. // This Jenkinsfile will build a builder image and then run the actual build and tests inside this image
  2. // It's very important to not execute any scripts outside of the builder container, as it's our protection against
  3. // external developers bringing in harmful code into Jenkins.
  4. // Jenkins will only run the build if this Jenkinsfile was not modified in an external pull request. Only branches
  5. // which are part of the RuxCrypto repo will allow modification to the Jenkinsfile.
  6. def targets = [
  7. 'win32',
  8. 'win64',
  9. 'linux32',
  10. 'linux64',
  11. 'linux64_nowallet',
  12. 'linux64_release',
  13. 'mac',
  14. ]
  15. def tasks = [:]
  16. for(int i = 0; i < targets.size(); i++) {
  17. def target = targets[i]
  18. tasks["${target}"] = {
  19. node {
  20. def BUILD_NUMBER = sh(returnStdout: true, script: 'echo $BUILD_NUMBER').trim()
  21. def BRANCH_NAME = sh(returnStdout: true, script: 'echo $BRANCH_NAME').trim()
  22. def UID = sh(returnStdout: true, script: 'id -u').trim()
  23. def HOME = sh(returnStdout: true, script: 'echo $HOME').trim()
  24. def pwd = sh(returnStdout: true, script: 'pwd').trim()
  25. checkout scm
  26. def env = [
  27. "BUILD_TARGET=${target}",
  28. "PULL_REQUEST=false",
  29. "JOB_NUMBER=${BUILD_NUMBER}",
  30. ]
  31. withEnv(env) {
  32. def builderImageName="ruxcrypto-builder-${target}"
  33. def builderImage
  34. stage("${target}/builder-image") {
  35. builderImage = docker.build("${builderImageName}", "--build-arg BUILD_TARGET=${target} ci -f ci/Dockerfile.builder")
  36. }
  37. builderImage.inside("-t") {
  38. // copy source into fixed path
  39. // we must build under the same path everytime as otherwise caches won't work properly
  40. sh "cp -ra ${pwd}/. /ruxcrypto-src/"
  41. // restore cache
  42. def hasCache = false
  43. try {
  44. copyArtifacts(projectName: "ruxcryptopay-ruxcrypto/${BRANCH_NAME}", optional: true, selector: lastSuccessful(), filter: "ci-cache-${target}.tar.gz")
  45. } catch (Exception e) {
  46. }
  47. if (fileExists("ci-cache-${target}.tar.gz")) {
  48. hasCache = true
  49. echo "Using cache from ruxcryptopay-ruxcrypto/${BRANCH_NAME}"
  50. } else {
  51. try {
  52. copyArtifacts(projectName: 'ruxcryptopay-ruxcrypto/develop', optional: true, selector: lastSuccessful(), filter: "ci-cache-${target}.tar.gz");
  53. } catch (Exception e) {
  54. }
  55. if (fileExists("ci-cache-${target}.tar.gz")) {
  56. hasCache = true
  57. echo "Using cache from ruxcryptopay-ruxcrypto/develop"
  58. }
  59. }
  60. if (hasCache) {
  61. sh "cd /ruxcrypto-src && tar xzf ${pwd}/ci-cache-${target}.tar.gz"
  62. } else {
  63. sh "mkdir -p /ruxcrypto-src/ci-cache-${target}"
  64. }
  65. stage("${target}/depends") {
  66. sh 'cd /ruxcrypto-src && ./ci/build_depends.sh'
  67. }
  68. stage("${target}/build") {
  69. sh 'cd /ruxcrypto-src && ./ci/build_src.sh'
  70. }
  71. stage("${target}/test") {
  72. sh 'cd /ruxcrypto-src && ./ci/test_unittests.sh'
  73. }
  74. stage("${target}/test") {
  75. sh 'cd /ruxcrypto-src && ./ci/test_integrationtests.sh'
  76. }
  77. // archive cache and copy it into the jenkins workspace
  78. sh "cd /ruxcrypto-src && tar czfv ci-cache-${target}.tar.gz ci-cache-${target} && cp ci-cache-${target}.tar.gz ${pwd}/"
  79. }
  80. // upload cache
  81. archiveArtifacts artifacts: "ci-cache-${target}.tar.gz", fingerprint: true
  82. }
  83. }
  84. }
  85. }
  86. parallel tasks