forked from jfrog/jfrog-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
50 lines (45 loc) · 1.96 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
node {
def architectures = [
[pkg: 'jfrog-cli-linux-386', goos: 'linux', goarch: '386', fileExtention: ''],
[pkg: 'jfrog-cli-linux-amd64', goos: 'linux', goarch: 'amd64', fileExtention: ''],
[pkg: 'jfrog-cli-mac-386', goos: 'darwin', goarch: 'amd64', fileExtention: ''],
[pkg: 'jfrog-cli-windows-amd64', goos: 'windows', goarch: 'amd64', fileExtention: '.exe']
]
subject = 'jfrog'
repo = 'jfrog-cli-go'
sh 'rm -rf temp'
sh 'mkdir temp'
def goRoot = tool 'go-1.7.1'
dir('temp'){
cliWorkspace = pwd()
withEnv(["GOROOT=$goRoot","GOPATH=${cliWorkspace}","PATH+GOROOT=${goRoot}/bin", "JFROG_CLI_OFFER_CONFIG=false"]) {
stage 'Go get'
sh 'go get -f -u github.com/jfrogdev/jfrog-cli-go/jfrog-cli/jfrog'
if (BRANCH?.trim()) {
dir("src/github.com/jfrogdev/jfrog-cli-go/jfrog-cli/jfrog") {
sh "git checkout $BRANCH"
sh 'go install'
}
}
sh 'bin/jfrog --version > version'
version = readFile('version').trim().split(" ")[2]
print "publishing version: $version"
for (int i = 0; i < architectures.size(); i++) {
def currentBuild = architectures[i]
stage "Build ${currentBuild.pkg}"
buildAndUpload(currentBuild.goos, currentBuild.goarch, currentBuild.pkg, currentBuild.fileExtention)
}
}
}
}
def uploadToBintray(pkg, fileExtension) {
sh """#!/bin/bash
bin/jfrog bt u $cliWorkspace/jfrog$fileExtension $subject/$repo/$pkg/$version /$version/$pkg/ --user=$USER_NAME --key=$KEY
"""
}
def buildAndUpload(goos, goarch, pkg, fileExtension) {
sh "env GOOS=$goos GOARCH=$goarch go build github.com/jfrogdev/jfrog-cli-go/jfrog-cli/jfrog"
def extension = fileExtension == null ? '' : fileExtension
uploadToBintray(pkg, extension)
sh "rm jfrog$extension"
}