-
Notifications
You must be signed in to change notification settings - Fork 16
/
Jenkinsfile
72 lines (68 loc) · 3.47 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
pipeline {
agent any
tools {
go 'go-1.17'
}
environment {
AWS_REGION = 'us-east-1'
GO114MODULE = 'on'
CGO_ENABLED = 0
GOPATH = "${JENKINS_HOME}/jobs/${JOB_NAME}/builds/${BUILD_ID}"
}
stages {
stage('Go Vet') {
steps {
sh 'go version'
sh 'go vet'
}
}
stage('Go Test') {
steps {
withCredentials([
conjurSecretCredential(credentialsId: 'data-vault-D-App-CybrCLI-Application-CyberArk-vault-infamous.privilegecloud.cyberark.cloud-Svc_CybrCLI-username', variable: 'PAS_USERNAME'),
conjurSecretCredential(credentialsId: 'data-vault-D-App-CybrCLI-Application-CyberArk-vault-infamous.privilegecloud.cyberark.cloud-Svc_CybrCLI-password', variable: 'PAS_PASSWORD'),
conjurSecretCredential(credentialsId: 'data-vault-D-App-CybrCLI-ccp-client-certificate-password', variable: 'CCP_CLIENT_CERT'),
conjurSecretCredential(credentialsId: 'data-vault-D-App-CybrCLI-ccp-priv-key-password', variable: 'CCP_CLIENT_PRIVATE_KEY')
]) {
sh '''
set +x
PAS_HOSTNAME=https://infamous.privilegecloud.cyberark.cloud
CCP_CLIENT_CERT=$(echo $CCP_CLIENT_CERT | base64 --decode)
CCP_CLIENT_PRIVATE_KEY=$(echo $CCP_CLIENT_PRIVATE_KEY | base64 --decode)
set -x
go test -v ./pkg/cybr/api
'''
}
}
}
stage('Go Build') {
steps {
echo "Making Linux x64 binary..."
sh 'GOOS=linux GOARCH=amd64 go build -o ./bin/${BUILD_TIMESTAMP}_linux_cybr .'
echo "Making Darwin x64 binary..."
sh 'GOOS=darwin GOARCH=amd64 go build -o ./bin/${BUILD_TIMESTAMP}_darwin_cybr .'
echo "Making Homebrew Darwin x64 binary..."
sh 'GOOS=darwin GOARCH=amd64 go build -o ./bin/${BUILD_TIMESTAMP}_cybr'
echo "Making Darwin ARM binary..."
sh 'GOOS=darwin GOARCH=arm64 go build -o ./bin/${BUILD_TIMESTAMP}_darwin_arm64_cybr .'
echo "Making Windows x64 binary..."
sh 'GOOS=windows GOARCH=amd64 go build -o ./bin/${BUILD_TIMESTAMP}_windows_cybr.exe .'
echo "Finished making - files output to ./bin/"
}
}
stage('Release to AWS S3') {
steps {
withCredentials([
conjurSecretCredential(credentialsId: 'SyncVault-LOB_CI-D-App-CybrCLI-Cloud Service-AWSAccessKeys-jenkins_cybr-cli-awsaccesskeyid', variable: 'AWS_ACCESS_KEY_ID'),
conjurSecretCredential(credentialsId: 'SyncVault-LOB_CI-D-App-CybrCLI-Cloud Service-AWSAccessKeys-jenkins_cybr-cli-password', variable: 'AWS_SECRET_ACCESS_KEY')
]) {
sh 'aws s3 cp ./bin/${BUILD_TIMESTAMP}_linux_cybr s3://cybr-cli-releases'
sh 'aws s3 cp ./bin/${BUILD_TIMESTAMP}_darwin_cybr s3://cybr-cli-releases'
sh 'aws s3 cp ./bin/${BUILD_TIMESTAMP}_cybr s3://cybr-cli-releases'
sh 'aws s3 cp ./bin/${BUILD_TIMESTAMP}_darwin_arm64_cybr s3://cybr-cli-releases'
sh 'aws s3 cp ./bin/${BUILD_TIMESTAMP}_windows_cybr.exe s3://cybr-cli-releases'
}
}
}
}
}