|
| 1 | +@Library('tenable.common') |
| 2 | +import com.tenable.jenkins.* |
| 3 | +import com.tenable.jenkins.builds.* |
| 4 | +import com.tenable.jenkins.builds.checkmarx.* |
| 5 | +import com.tenable.jenkins.builds.nexusiq.* |
| 6 | +import com.tenable.jenkins.builds.onprem.* |
| 7 | +import com.tenable.jenkins.common.* |
| 8 | +import com.tenable.jenkins.deployments.* |
| 9 | +import com.tenable.jenkins.msg.* |
| 10 | +import com.tenable.jenkins.slack2.Slack |
| 11 | + |
| 12 | +def projectProperties = [ |
| 13 | + [$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '5']], |
| 14 | + disableConcurrentBuilds(), |
| 15 | + disableResume(), |
| 16 | + [$class: 'ParametersDefinitionProperty', parameterDefinitions: |
| 17 | + [[$class: 'StringParameterDefinition', defaultValue: 'qa-milestone', description: '', name: 'CAT_SITE']]] |
| 18 | +] |
| 19 | + |
| 20 | +properties(projectProperties) |
| 21 | + |
| 22 | +Common common = new Common(this) |
| 23 | +BuildsCommon buildsCommon = new BuildsCommon(this) |
| 24 | + |
| 25 | +try { |
| 26 | + node(Constants.DOCKERNODE) { |
| 27 | + buildsCommon.cleanup() |
| 28 | + |
| 29 | + stage('scm auto') { |
| 30 | + dir('automation') { |
| 31 | + git(branch:'master', |
| 32 | + changelog:false, |
| 33 | + credentialsId:'githubkey', |
| 34 | + poll:false, |
| 35 | + url: "${Constants.SSHGITHUBPRODUCT}catium-tenableio.git") |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + docker.withRegistry(Constants.AWS_DOCKER_REGISTRY) { |
| 40 | + docker.image(Constants.DOCKER_CI_VULNAUTOMATION_BASE).inside('-u root') { |
| 41 | + stage('build auto') { |
| 42 | + timeout(time: 24, unit: Constants.HOURS) { |
| 43 | + buildsCommon.prepareGit() |
| 44 | + |
| 45 | + sshagent([Constants.GITHUBKEY]) { |
| 46 | + sh """ |
| 47 | + cd automation |
| 48 | + export JENKINS_NODE_COOKIE= |
| 49 | + unset JENKINS_NODE_COOKIE |
| 50 | +
|
| 51 | + python3 autosetup.py catium --all --no-venv 2>&1 |
| 52 | +
|
| 53 | + export PYTHONHASHSEED=0 |
| 54 | + export PYTHONPATH=. |
| 55 | + export CAT_LOG_LEVEL_CONSOLE=INFO |
| 56 | + export CAT_SITE=${params.CAT_SITE} |
| 57 | +
|
| 58 | + pwd |
| 59 | +
|
| 60 | + mkdir ../tenableio-sdk |
| 61 | + python3 tenableio/commandline/sdk_test_container.py --create_container --raw --agents 5 |
| 62 | +
|
| 63 | + chmod -R 777 ../tenableio-sdk |
| 64 | + """.stripIndent() |
| 65 | + stash includes: '**/tenableio-sdk/tio_config.txt', name: 'Config' |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + buildsCommon.cleanup() |
| 73 | + deleteDir() |
| 74 | + |
| 75 | + stage('scm java') { |
| 76 | + checkout scm |
| 77 | + unstash 'Config' |
| 78 | + } |
| 79 | + |
| 80 | + docker.withRegistry(Constants.AWS_DOCKER_REGISTRY) { |
| 81 | + docker.image(Constants.DOCKER_CI_JAVA_BASE).inside { |
| 82 | + stage('build java') { |
| 83 | + try { |
| 84 | + timeout(time: 24, unit: Constants.HOURS) { |
| 85 | + sh ''' |
| 86 | + find . |
| 87 | + cat ./tenableio-sdk/tio_config.txt | sed 's/^/systemProp./g' > gradle.properties |
| 88 | +
|
| 89 | + cat gradle.properties |
| 90 | +
|
| 91 | + chmod +x gradlew |
| 92 | + ./gradlew build |
| 93 | + '''.stripIndent() |
| 94 | + } |
| 95 | + } |
| 96 | + finally { |
| 97 | + step([$class: 'JUnitResultArchiver', testResults: 'build/test-results/test/*.xml']) |
| 98 | + } |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + common.setResultIfNotSet(Constants.JSUCCESS) |
| 104 | + } |
| 105 | +} |
| 106 | +catch (ex) { |
| 107 | + common.logException(ex) |
| 108 | + common.setResultAbortedOrFailure() |
| 109 | +} |
| 110 | +finally { |
| 111 | + common.setResultIfNotSet(Constants.JFAILURE) |
| 112 | + |
| 113 | + String auser = common.getAbortingUsername() |
| 114 | + String tests = common.getTestResults() |
| 115 | + String took = '\nTook: ' + common.getDuration() |
| 116 | + |
| 117 | + Slack slack = new Slack(this) |
| 118 | + |
| 119 | + messageAttachment = slack.helper.getDecoratedFinishMsg( |
| 120 | + 'Tenable SDK Java build finished with result: ', |
| 121 | + "Built off branch ${env.BRANCH_NAME}" + tests + took + auser) |
| 122 | + messageAttachment.channel = '#sdk' |
| 123 | + |
| 124 | + slack.postMessage(messageAttachment) |
| 125 | +} |
| 126 | + |
0 commit comments