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