-
Notifications
You must be signed in to change notification settings - Fork 1
/
jenkins
79 lines (74 loc) · 3.08 KB
/
jenkins
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
pipeline {
agent any
environment {
// Get the VM Credentials to use later in Pipeline.
USER_CREDENTIALS = credentials('vm-ending-with-138')
SONAR_KEY = credentials('sonarqube-cloudnative')
DEVEXKEY = credentials('devexpress-key')
// Copy Repo to this location
COPY_DIR = '/tmp/cloudnativedotnet'
}
stages {
stage("SonarQube Analysis") {
steps {
withSonarQubeEnv("SonarQube") {
sh '''
export PATH=$PATH:$HOME/.dotnet/tools
dotnet test CloudAccelerator.sln /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
dotnet sonarscanner begin /k:"cloud-native-dotnet" /d:sonar.host.url="http://sonarqube:9000" /d:sonar.login=$SONAR_KEY /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" /d:sonar.coverage.exclusions="**/**Test*.cs"
dotnet build CloudAccelerator.sln
dotnet sonarscanner end /d:sonar.login=$SONAR_KEY
'''
}
}
}
// stage("Quality Gate") {
// steps {
// timeout(time: 2, unit: 'MINUTES') {
// waitForQualityGate abortPipeline: true
// }
// }
// }
stage("Deploy to Develoment Server") {
when {
expression {
return env.GIT_BRANCH == "origin/ci_cd_dev_temp"
}
}
steps {
sh '''
ssh [email protected] rm -rf $COPY_DIR
scp -r ${WORKSPACE} [email protected]:$COPY_DIR
ssh [email protected] "
cd $COPY_DIR
echo $USER_CREDENTIALS_PSW | sudo -S docker-compose -f docker-compose.yml -f docker-compose.dev.yml build --no-cache --build-arg DEVEXKEY=$DEVEXKEY
echo $USER_CREDENTIALS_PSW | sudo -S docker-compose -f docker-compose.yml -f docker-compose.dev.yml -p damco---cloud-native-development-accelerators up --force-recreate -d"
'''
}
}
stage("Deploy to QA Server") {
when {
expression {
return env.GIT_BRANCH == "origin/ci_cd_qa"
}
}
steps {
sh '''
docker-compose -f docker-compose.yml -f docker-compose.qa.yml build --no-cache --build-arg DEVEXKEY=$DEVEXKEY
docker-compose -f docker-compose.yml -f docker-compose.qa.yml -p damco---cloud-native-development-accelerators up -d
'''
}
}
}
post {
always {
cleanWs()
}
success {
emailext (attachLog: true, body: '${JOB_NAME} succeed. Open ${BUILD_URL} to check for more details.', subject: '${BUILD_TAG} Succeed', to: '[email protected],[email protected]')
}
failure {
emailext (attachLog: true, body: '${JOB_NAME} failed. Open ${BUILD_URL} to check for more details.', subject: '${BUILD_TAG} Failed', to: '[email protected],[email protected]')
}
}
}