-
Notifications
You must be signed in to change notification settings - Fork 21
/
Jenkinsfile
65 lines (65 loc) · 2 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
pipeline {
agent {
kubernetes {
label 'go-pipeline-pod'
yamlFile 'podTemplate/go-pipeline-pod.yaml'
idleMinutes 120
}
}
stages {
stage('Build') {
steps {
container('golang'){
sh 'go build'
}
}
}
stage('Unit Tests') {
steps {
container('golang'){
sh 'go test ./... -run Unit'
}
}
}
stage('Docker Build') {
steps {
container('docker'){
sh "docker build -t partnership-public-images.jfrog.io/goci-example:latest ."
}
}
}
stage('Docker Push to Repo') {
steps {
container('docker'){
script {
docker.withRegistry( 'https://partnership-public-images.jfrog.io', 'gociexamplerepo' ) {
sh "docker push partnership-public-images.jfrog.io/goci-example:latest"
}
}
}
}
}
stage('Publish Build Info') {
environment {
JFROG_CLI_OFFER_CONFIG = false
}
steps {
container('jfrog-cli-go'){
withCredentials([usernamePassword(credentialsId: 'gociexamplerepo', passwordVariable: 'APIKEY', usernameVariable: 'USER')]) {
sh "jfrog rt bce $JOB_NAME $BUILD_NUMBER"
sh "jfrog rt bag $JOB_NAME $BUILD_NUMBER"
sh "jfrog rt bad $JOB_NAME $BUILD_NUMBER \"go.*\""
sh "jfrog rt bp --build-url=https://jenkins.openshiftk8s.com/ --url=https://partnership.jfrog.io/artifactory --user=$USER --apikey=$APIKEY $JOB_NAME $BUILD_NUMBER"
}
}
}
}
}
post {
success {
script {
sh "curl -v -XPOST -H \"authorization: Basic amVmZmY6amZyMGdqM25rMW5z\" \"https://partnership-pipelines-api.jfrog.io/v1/projectIntegrations/17/hook\" -d '{\"buildName\":\"$JOB_NAME\",\"buildNumber\":\"$BUILD_NUMBER\",\"buildInfoResourceName\":\"jenkinsBuildInfo\"}' -H \"Content-Type: application/json\""
}
}
}
}