Skip to content

Commit b575820

Browse files
authored
Merge pull request #48 from Daimler/develop
Merge develop into master
2 parents 3057778 + 184ca62 commit b575820

File tree

149 files changed

+3808
-534
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+3808
-534
lines changed

continous-integration-multibranch-pipeline.jenkins

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ pipeline {
1414

1515
environment {
1616
SECHUB_TRUSTALL= "true" // necessary for integration tests
17+
SECHUB_SCAN_ENABLED = getStringCredentialsOrUndefined('sechub-scan-enabled')
18+
1719
}
1820

1921
stages {
2022

2123
stage('Initialize') {
2224
steps {
2325
script{
26+
2427
sechubGitBranch = sh(returnStdout: true, script: "git branch | grep \\* | cut -d ' ' -f2").trim()
2528
echo "Branch is $sechubGitBranch"
26-
2729
if( sechubGitBranch == "master" ) {
2830
echo "Cancel build , because master is build on by release-pipeline.jenkins!"
2931
currentBuild.result = 'SUCCESS'
@@ -32,7 +34,6 @@ pipeline {
3234

3335
}
3436

35-
3637
}
3738
}
3839

@@ -59,7 +60,7 @@ pipeline {
5960
}
6061
stage('Build CLI') {
6162
steps {
62-
script{failed
63+
script{
6364
callGradleWrapper(':sechub-cli:buildGo :sechub-cli:testGo')
6465
}
6566
}
@@ -77,6 +78,29 @@ pipeline {
7778
}
7879
}
7980

81+
stage('Security scan') {
82+
when{
83+
not {
84+
environment name: 'SECHUB_SCAN_ENABLED', value: '<undefined>'
85+
}
86+
}
87+
88+
89+
environment {
90+
SECHUB_USERID = credentials('sechub-userid')
91+
SECHUB_APITOKEN = credentials('sechub-api-token')
92+
SECHUB_SERVER= credentials('sechub-server')
93+
94+
}
95+
steps {
96+
97+
script{
98+
executeSecHubScan()
99+
}
100+
}
101+
102+
}
103+
80104
stage('Build Documentation') {
81105
steps {
82106
script{
@@ -106,7 +130,6 @@ pipeline {
106130
}
107131
always {
108132
archive '**/integrationtest-server.log'
109-
110133
junit '**/build/test-results/*/TEST-*.xml'
111134

112135
}
@@ -135,6 +158,36 @@ void callGradleWrapper(String gradleCommand) {
135158
}
136159
}
137160

161+
void executeSecHubScan() {
162+
163+
apiToken = env.SECHUB_APITOKEN
164+
userid= env.SECHUB_USERID
165+
server= env.SECHUB_SERVER
166+
167+
if (isUnix()) {
168+
sh "sechub -project sechub -apitoken ${apiToken} -user ${userid} -server ${server} scan"
169+
} else {
170+
bat "sechub -project sechub -apitoken ${apiToken} -user ${userid} -server ${server} scan"
171+
}
172+
}
173+
174+
Object getStringCredentialsOrUndefined(String id){
175+
if (stringCredentialsExist(id)){
176+
return credentials(id)
177+
}
178+
return '<undefined>'
179+
}
180+
181+
boolean stringCredentialsExist(String id) {
182+
try {
183+
withCredentials([string(credentialsId: id, variable: 'irrelevant')]) {
184+
true
185+
}
186+
} catch (_) {
187+
false
188+
}
189+
}
190+
138191
/**
139192
* This class is necessary because jenkins - at least in version 2.150.2 - does not correct handle
140193
* GIT tags and branches. Multi pipeline builds do not even checkout the tags. Normal pipeline builds do checkout the tags,

docs/latest/images/diagram_business_context_overview.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/latest/images/diagram_sechub_server.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/latest/images/diagram_target_architecture.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/latest/images/diagram_technical_context_overview.svg

Lines changed: 1 addition & 1 deletion
Loading
Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)