Skip to content

Commit 58593f1

Browse files
JGC-489 - Fix release (#3305)
* JGC-439 - Fix darwin skip * JGC-439 - Fix darwin skip * JGC-439 - Fix go version * JGC-439 - Fix go version * JGC-439 - Fix go version * JGC-439 - Fix git checkout * JGC-439 - Fix git checkout * JGC-439 - Fix git checkout * JGC-439 - Add logging for script uploads in Jenkinsfile * JGC-439 - Add build logging for file and architecture in Jenkinsfile * JGC-439 - Enhance release bundle creation in Jenkinsfile with error handling and logging * JGC-439 - Refactor error handling and logging in release bundle creation script within Jenkinsfile * JGC-439 - Improve NPM package publishing in Jenkinsfile with enhanced error handling for existing versions --------- Co-authored-by: github-actions[bot] <[email protected]>
1 parent d3a216e commit 58593f1

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

Jenkinsfile

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,18 @@ node("docker-ubuntu20-xlarge") {
3939
identifier = 'v2-jf'
4040
nodeVersion = 'v8.17.0'
4141

42-
masterBranch = 'master'
43-
4442
releaseVersion = ''
4543

4644
repo = 'jfrog-cli'
4745
sh 'rm -rf temp'
4846
sh 'mkdir temp'
49-
def goRoot = tool 'go-1.25.4'
47+
def goRoot = tool 'go-1.25.5'
5048
env.GOROOT="$goRoot"
5149
env.PATH+=":${goRoot}/bin:/tmp/node-${nodeVersion}-linux-x64/bin"
5250
env.GO111MODULE="on"
5351
env.CI=true
54-
env.JFROG_CLI_LOG_LEVEL="DEBUG"
52+
env.JFROG_CLI_LOG_LEVEL="INFO"
53+
env.JFROG_CLI_REPORT_USAGE="false"
5554

5655
dir('temp') {
5756
sh "cat /etc/lsb-release"
@@ -160,6 +159,7 @@ def runRelease(architectures) {
160159
stage("Publish latest scripts") {
161160
withCredentials([string(credentialsId: 'jfrog-cli-automation', variable: 'JFROG_CLI_AUTOMATION_ACCESS_TOKEN')]) {
162161
options = "--url https://releases.jfrog.io/artifactory --access-token=$JFROG_CLI_AUTOMATION_ACCESS_TOKEN"
162+
print "Copying latest scripts from jfrog-cli/$identifier/$version/scripts/ to jfrog-cli/$identifier/scripts/"
163163
sh """#!/bin/bash
164164
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/getCli.sh jfrog-cli/$identifier/scripts/ --flat $options --fail-no-op
165165
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/install-cli.sh jfrog-cli/$identifier/scripts/ --flat $options --fail-no-op
@@ -212,7 +212,6 @@ def runRelease(architectures) {
212212

213213
def setReleaseVersion() {
214214
dir("$cliWorkspace/$repo") {
215-
sh "git checkout $masterBranch"
216215
sh "build/build.sh"
217216
releaseVersion = getCliVersion("./jf")
218217
}
@@ -337,7 +336,9 @@ def uploadCli(architectures) {
337336
stage("Build and upload ${currentBuild.pkg}") {
338337
// MacOS binaries should be downloaded from GitHub packages, as they are signed there.
339338
if (currentBuild.goos == 'darwin') {
340-
uploadSignedDarwinBinaries(currentBuild.goarch,currentBuild.pkg)
339+
if (params.RUN_DARWIN_WORKFLOW) {
340+
uploadSignedDarwinBinaries(currentBuild.goarch,currentBuild.pkg)
341+
}
341342
} else {
342343
buildAndUpload(currentBuild.goos, currentBuild.goarch, currentBuild.pkg, currentBuild.fileExtension)
343344
}
@@ -395,30 +396,35 @@ def pushDockerImageVersion(name, version) {
395396
}
396397

397398
def uploadGetCliToJfrogRepo21() {
399+
print "Uploading $jfrogCliRepoDir/build/getcli/${cliExecutableName}.sh to ecosys-jfrog-cli/$identifier/$version/scripts/getCli.sh"
398400
sh """#!/bin/bash
399401
$builderPath rt u $jfrogCliRepoDir/build/getcli/${cliExecutableName}.sh ecosys-jfrog-cli/$identifier/$version/scripts/getCli.sh --flat
400402
"""
401403
}
402404

403405
def uploadInstallCliToJfrogRepo21() {
406+
print "Uploading $jfrogCliRepoDir/build/installcli/${cliExecutableName}.sh to ecosys-jfrog-cli/$identifier/$version/scripts/install-cli.sh"
404407
sh """#!/bin/bash
405408
$builderPath rt u $jfrogCliRepoDir/build/installcli/${cliExecutableName}.sh ecosys-jfrog-cli/$identifier/$version/scripts/install-cli.sh --flat
406409
"""
407410
}
408411

409412
def uploadSetupCliToJfrogRepo21() {
413+
print "Uploading $jfrogCliRepoDir/build/setupcli/${cliExecutableName}.sh to ecosys-jfrog-cli/$identifier/$version/scripts/setup-cli.sh"
410414
sh """#!/bin/bash
411415
$builderPath rt u $jfrogCliRepoDir/build/setupcli/${cliExecutableName}.sh ecosys-jfrog-cli/$identifier/$version/scripts/setup-cli.sh --flat
412416
"""
413417
}
414418

415419
def uploadGitLabSetupToJfrogRepo21() {
420+
print "Uploading $jfrogCliRepoDir/build/gitlab/(*) to ecosys-jfrog-cli/$identifier/$version/scripts/gitlab/{1}"
416421
sh """#!/bin/bash
417422
$builderPath rt u "$jfrogCliRepoDir/build/gitlab/(*)" "ecosys-jfrog-cli/$identifier/$version/scripts/gitlab/{1}"
418423
"""
419424
}
420425

421426
def uploadBinaryToJfrogRepo21(pkg, fileName) {
427+
print "Uploading $jfrogCliRepoDir/$fileName to ecosys-jfrog-cli/$identifier/$version/$pkg/"
422428
sh """#!/bin/bash
423429
$builderPath rt u $jfrogCliRepoDir/$fileName ecosys-jfrog-cli/$identifier/$version/$pkg/ --flat
424430
"""
@@ -428,6 +434,7 @@ def build(goos, goarch, pkg, fileName) {
428434
dir("${jfrogCliRepoDir}") {
429435
env.GOOS="$goos"
430436
env.GOARCH="$goarch"
437+
print "Building $fileName on $goos $goarch"
431438
sh "build/build.sh $fileName"
432439
sh "chmod +x $fileName"
433440
// Remove goos and goarch env var to prevent interfering with following builds.
@@ -458,7 +465,21 @@ def buildAndUpload(goos, goarch, pkg, fileExtension) {
458465
}
459466

460467
def distributeToReleases(stage, version, rbcSpecName) {
461-
sh """$builderPath ds rbc $stage-rb-$identifier $version --spec=${cliWorkspace}/${repo}/build/release_specs/$rbcSpecName --spec-vars="VERSION=$version;IDENTIFIER=$identifier" --sign"""
468+
sh """#!/bin/bash
469+
output=\$($builderPath ds rbc $stage-rb-$identifier $version --spec=${cliWorkspace}/${repo}/build/release_specs/$rbcSpecName --spec-vars="VERSION=$version;IDENTIFIER=$identifier" --sign 2>&1)
470+
exit_code=\$?
471+
if [[ \$exit_code -ne 0 ]]; then
472+
if echo "\$output" | grep -q "already exists"; then
473+
echo "Release bundle creation skipped - already exists"
474+
exit 0
475+
else
476+
echo "\$output"
477+
exit \$exit_code
478+
fi
479+
else
480+
echo "\$output"
481+
fi
482+
"""
462483
sh "$builderPath ds rbd $stage-rb-$identifier $version --site=releases.jfrog.io --sync"
463484
}
464485

@@ -468,7 +489,19 @@ def publishNpmPackage(jfrogCliRepoDir) {
468489
sh '''#!/bin/bash
469490
echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > .npmrc
470491
echo "registry=https://registry.npmjs.org" >> .npmrc
471-
npm publish
492+
output=$(npm publish 2>&1)
493+
exit_code=$?
494+
if [[ $exit_code -ne 0 ]]; then
495+
if echo "$output" | grep -qi "You cannot publish over the previously published versions"; then
496+
echo "NPM package publish skipped - already exists"
497+
exit 0
498+
else
499+
echo "$output"
500+
exit $exit_code
501+
fi
502+
else
503+
echo "$output"
504+
fi
472505
'''
473506
}
474507
}

build/docker/slim/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ARG repo_name_21
22
# Remove ${repo_name_21} to pull from Docker Hub.
3-
FROM ${repo_name_21}/jfrog-docker/golang:1.25.4-alpine as builder
3+
FROM ${repo_name_21}/jfrog-docker/golang:1.25.5-alpine as builder
44
ARG image_name=jfrog-cli
55
ARG cli_executable_name
66
WORKDIR /${image_name}

0 commit comments

Comments
 (0)