|
| 1 | +// This Jenkinsfile is used by Jenkins to run the OrthoinferenceStableIdentifierHistory step of Reactome's release. |
| 2 | +// It requires that the Orthoinference step has been run successfully before it can be run. |
| 3 | + |
| 4 | +import org.reactome.release.jenkins.utilities.Utilities |
| 5 | + |
| 6 | +// Shared library maintained at 'release-jenkins-utils' repository. |
| 7 | +def utils = new Utilities() |
| 8 | + |
| 9 | +pipeline { |
| 10 | + agent any |
| 11 | + |
| 12 | + stages { |
| 13 | + // This stage checks that an upstream project, Orthoinference, was run successfully for its last build. |
| 14 | + stage('Check if Orthoinference build succeeded'){ |
| 15 | + steps{ |
| 16 | + script{ |
| 17 | + utils.checkUpstreamBuildsSucceeded("Relational-Database-Updates/job/Orthoinference") |
| 18 | + } |
| 19 | + } |
| 20 | + } |
| 21 | + // Backs up the release_current and stable_identifiers databases. |
| 22 | + stage('Setup: Back up DBs'){ |
| 23 | + steps{ |
| 24 | + script{ |
| 25 | + dir('ortho-stable-id-history'){ |
| 26 | + withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){ |
| 27 | + utils.takeDatabaseDumpAndGzip("${env.RELEASE_CURRENT_DB}", "ortho_stable_id_history", "before", "${env.RELEASE_SERVER}") |
| 28 | + utils.takeDatabaseDumpAndGzip("${env.STABLE_IDENTIFIERS_DB}", "ortho_stable_id_history", "before", "${env.RELEASE_SERVER}") |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + // Builds the jar file that will be used. |
| 35 | + stage('Setup: Build jar file'){ |
| 36 | + steps{ |
| 37 | + script{ |
| 38 | + dir('ortho-stable-id-history'){ |
| 39 | + utils.buildJarFile() |
| 40 | + } |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + // Runs the perl 'save_stable_id_history.pl' script. |
| 45 | + stage('Main: Save StableIdentifier History'){ |
| 46 | + steps{ |
| 47 | + script{ |
| 48 | + dir('ortho-stable-id-history'){ |
| 49 | + withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){ |
| 50 | + def releaseVersion = utils.getReleaseVersion() |
| 51 | + sh "perl ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/save_stable_id_history.pl -db ${env.RELEASE_CURRENT_DB} -sdb ${env.STABLE_IDENTIFIERS_DB} -host localhost -user $user -pass $pass -release ${releaseVersion}" |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + } |
| 57 | + // Runs the perl 'old_stable_id_mapping.pl' script. |
| 58 | + stage('Main: Old StableIdentifier Mapping'){ |
| 59 | + steps{ |
| 60 | + script{ |
| 61 | + dir('ortho-stable-id-history'){ |
| 62 | + // Download 'stable_id_mapping.stored_data' from S3 |
| 63 | + sh "aws s3 cp ${env.S3_RELEASE_DIRECTORY_URL}/supplementary_files/stable_id_mapping.stored_data.zip ." |
| 64 | + sh "unzip stable_id_mapping.stored_data.zip" |
| 65 | + // Ensure that the file is in the same location as the Perl script |
| 66 | + sh "cp ./stable_id_mapping.stored_data ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/stable_id_mapping.stored_data" |
| 67 | + withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){ |
| 68 | + sh "perl ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/old_stable_id_mapping.pl -db ${env.RELEASE_CURRENT_DB} -host localhost" |
| 69 | + } |
| 70 | + sh "rm stable_id_mapping.stored_data*" |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + // Runs the StableIdentifier QA. |
| 76 | + stage('Post: Run StableIdentifier QA'){ |
| 77 | + steps{ |
| 78 | + script{ |
| 79 | + dir('ortho-stable-id-history') { |
| 80 | + withCredentials([file(credentialsId: 'Config', variable: 'ConfigFile')]) { |
| 81 | + sh "java -jar target/OrthoStableIdHistory-*-jar-with-dependencies.jar $ConfigFile" |
| 82 | + } |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + // Backs up the 'release_current' and 'stable_identifier' databases after the step has run. |
| 88 | + stage('Post: Backup DBs'){ |
| 89 | + steps{ |
| 90 | + script{ |
| 91 | + dir('ortho-stable-id-history'){ |
| 92 | + // Download 'stable_id_mapping.stored_data' from S3 |
| 93 | + def stableIdMappingStorFile = "stable_id_mapping.stored_data" |
| 94 | + sh "aws s3 --no-progress cp ${env.S3_RELEASE_DIRECTORY_URL}/supplementary_files/${stableIdMappingStorFile}.zip ." |
| 95 | + sh "unzip ${stableIdMappingStorFile}.zip" |
| 96 | + sh "mv ${stableIdMappingStorFile} ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/" |
| 97 | + withCredentials([usernamePassword(credentialsId: 'mySQLUsernamePassword', passwordVariable: 'pass', usernameVariable: 'user')]){ |
| 98 | + sh "perl ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/old_stable_id_mapping.pl -db ${env.RELEASE_CURRENT_DB} -host localhost" |
| 99 | + } |
| 100 | + sh "rm ${stableIdMappingStorFile}.zip" |
| 101 | + sh "rm ${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/${stableIdMappingStorFile}" |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + // This stage archives all logs and database backups produced by OrthoinferenceStableIdentifierHistory. |
| 107 | + stage('Post: Archive Outputs'){ |
| 108 | + steps{ |
| 109 | + script{ |
| 110 | + dir('ortho-stable-id-history'){ |
| 111 | + def dataFiles = [] |
| 112 | + def logFiles = ["${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/*log", "${env.ABS_RELEASE_PATH}/generate_stable_ids_orthoinference/*err"] |
| 113 | + def foldersToDelete = [] |
| 114 | + utils.cleanUpAndArchiveBuildFiles("ortho_stable_id_history", dataFiles, logFiles, foldersToDelete) |
| 115 | + } |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | + } |
| 120 | +} |
0 commit comments