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.gitian 4.8KB

  1. def targets = [
  2. 'linux',
  3. 'win',
  4. 'osx',
  5. ]
  6. def osslTarUrl = 'http://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz'
  7. def osslPatchUrl = 'https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch'
  8. def SDK_URL='https://bitcoincore.org/depends-sources/sdks'
  9. def OSX_SDK='10.11'
  10. def proc = 4
  11. def mem = 2000
  12. def repositoryUrl = "https://github.com/ruxcryptopay/ruxcrypto.git"
  13. def tasks = [:]
  14. for(int i = 0; i < targets.size(); i++) {
  15. def target = targets[i]
  16. tasks["${target}"] = {
  17. node {
  18. deleteDir() // cleanup workspace
  19. def pwd = sh(returnStdout: true, script: 'pwd').trim()
  20. def dockerGid = sh(returnStdout: true, script: "stat -c '%g' /var/run/docker.sock").trim()
  21. def BRANCH_NAME = sh(returnStdout: true, script: 'echo $BRANCH_NAME').trim()
  22. def commit = BRANCH_NAME
  23. def hasCache = false
  24. def gitianDescriptor
  25. stage("${target}/prepare") {
  26. dir('ruxcrypto') {
  27. checkout scm
  28. gitianDescriptor = readYaml file: "contrib/gitian-descriptors/gitian-${target}.yml"
  29. }
  30. dir('gitian-builder') {
  31. git url: 'https://github.com/ruxcryptopay/gitian-builder.git'
  32. }
  33. sh "mkdir -p ruxcryptocore-binaries"
  34. if (target == "osx") {
  35. dir('gitian-builder') {
  36. sh 'mkdir -p inputs'
  37. sh "curl --location --fail $SDK_URL/MacOSX${OSX_SDK}.sdk.tar.gz -o inputs/MacOSX${OSX_SDK}.sdk.tar.gz"
  38. }
  39. }
  40. // restore cache
  41. try {
  42. copyArtifacts(projectName: "ruxcryptopay-ruxcrypto-gitian-nightly/${BRANCH_NAME}", optional: true, selector: lastSuccessful(), filter: "cache-${gitianDescriptor.name}.tar.gz")
  43. } catch (Exception e) {
  44. }
  45. if (fileExists("cache-${gitianDescriptor.name}.tar.gz")) {
  46. hasCache = true
  47. echo "Using cache from ruxcryptopay-ruxcrypto-gitian-nightly/${BRANCH_NAME}"
  48. } else {
  49. try {
  50. copyArtifacts(projectName: 'ruxcryptopay-ruxcrypto-gitian-nightly/develop', optional: true, selector: lastSuccessful(), filter: "cache-${gitianDescriptor.name}.tar.gz");
  51. } catch (Exception e) {
  52. }
  53. if (fileExists("cache-${gitianDescriptor.name}.tar.gz")) {
  54. hasCache = true
  55. echo "Using cache from ruxcryptopay-ruxcrypto-gitian-nightly/develop"
  56. }
  57. }
  58. }
  59. def gitianImage
  60. stage("${target}/builder-image") {
  61. dir('ruxcrypto') {
  62. gitianImage = docker.build("ruxcrypto-gitian:${env.BUILD_ID}", 'ci -f ci/Dockerfile.gitian-builder')
  63. }
  64. }
  65. gitianImage.inside("--group-add ${dockerGid} -t -v \"/var/run/docker.sock:/var/run/docker.sock\"") {
  66. sh "mkdir -p gitian-builder/cache"
  67. if (hasCache) {
  68. sh "cd gitian-builder/cache && tar xzfv ../../cache-${gitianDescriptor.name}.tar.gz"
  69. }
  70. stage("${target}/download") {
  71. dir('gitian-builder') {
  72. sh "mkdir -p inputs"
  73. sh "cd inputs && curl -R -O ${osslPatchUrl}"
  74. sh "cd inputs && curl -R -O ${osslTarUrl}"
  75. sh "make -C ../ruxcrypto/depends download SOURCES_PATH=`pwd`/cache/common"
  76. }
  77. }
  78. stage("${target}/base-vm") {
  79. dir('gitian-builder') {
  80. sh "./bin/make-base-vm --suite bionic --arch amd64 --docker"
  81. }
  82. }
  83. stage("${target}/gbuild") {
  84. dir('gitian-builder') {
  85. // make sure an old version is not running
  86. sh "docker rm -fv gitian-target || true"
  87. try {
  88. sh """
  89. tail -F var/install.log &
  90. tail -F var/build.log &
  91. USE_DOCKER=1 ./bin/gbuild -j ${proc} -m ${mem} --commit ruxcrypto=${commit} --url ruxcrypto=${repositoryUrl} ../ruxcrypto/contrib/gitian-descriptors/gitian-${target}.yml
  92. RET=\$?
  93. # give the above tail calls enough time to print everything on failure
  94. sleep 2s
  95. exit \$RET
  96. """
  97. } finally {
  98. // make sure it doesn't run forever
  99. sh "docker rm -fv gitian-target || true"
  100. }
  101. sh "mv build/out/ruxcryptocore-* ../ruxcryptocore-binaries/"
  102. sh "mv build/out/src/ruxcryptocore-* ../ruxcryptocore-binaries/"
  103. }
  104. archiveArtifacts artifacts: 'ruxcryptocore-binaries/*', fingerprint: true
  105. }
  106. // TODO remove this in a few days (only needed to prune the old compressed file from Jenkins caches)
  107. sh "cd gitian-builder/cache && find -name ccache.tar.gz | xargs rm -f"
  108. sh "cd gitian-builder/cache && tar czfv ../../cache-${gitianDescriptor.name}.tar.gz common ${gitianDescriptor.name}"
  109. archiveArtifacts artifacts: "cache-${gitianDescriptor.name}.tar.gz", fingerprint: true
  110. }
  111. }
  112. }
  113. }
  114. parallel tasks