Skip to content

Commit

Permalink
Simplify Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
eyalbe4 committed Dec 25, 2023
1 parent b7403c8 commit 8449ad5
Showing 1 changed file with 55 additions and 59 deletions.
114 changes: 55 additions & 59 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ node("docker") {
}

stage('synchronize branches') {
if ("$EXECUTION_MODE".toString().equals("Build CLI")) {
masterBranch = 'v2'
devBranch = 'dev'
if (BRANCH?.trim() == 'v1') {
masterBranch = 'v1'
devBranch = 'dev-v1'
}
synchronizeBranches(masterBranch, devBranch)
masterBranch = 'v2'
devBranch = 'dev'
if (BRANCH?.trim() == 'v1') {
masterBranch = 'v1'
devBranch = 'dev-v1'
}
synchronizeBranches(masterBranch, devBranch)
}

stage('install npm') {
Expand Down Expand Up @@ -104,64 +102,62 @@ def runRelease(architectures) {
configRepo21()

try {
if ("$EXECUTION_MODE".toString().equals("Publish packages")) {
stage('Docker login') {
dockerLogin()
}

stage('Build and publish rpm and debian') {
buildRpmAndDeb(version, architectures)
}

stage('Npm publish') {
publishNpmPackage(jfrogCliRepoDir)
}

stage('Build and publish docker images') {
buildPublishDockerImages(version, jfrogCliRepoDir)
}

// Download cert files, to be used for signing the Windows executable, packaged by Chocolatey.
downloadToolsCert()
stage('Build and publish Chocolatey') {
publishChocoPackageWithRetries(version, jfrogCliRepoDir, architectures)
}
} else if ("$EXECUTION_MODE".toString().equals("Build CLI")) {
validateReleaseVersion()
if (identifier != "v2") {
stage("Audit") {
dir("$jfrogCliRepoDir") {
sh """#!/bin/bash
../$builderPath audit --fail=false
"""
}
validateReleaseVersion()
if (identifier != "v2") {
stage("Audit") {
dir("$jfrogCliRepoDir") {
sh """#!/bin/bash
../$builderPath audit --fail=false
"""
}
}
}

downloadToolsCert()
print "Uploading version $version to Repo21"
uploadCli(architectures)
stage("Distribute executables") {
distributeToReleases("ecosystem-jfrog-cli", version, "cli-rbc-spec.json")
}
stage("Publish latest scripts") {
withCredentials([string(credentialsId: 'jfrog-cli-automation', variable: 'JFROG_CLI_AUTOMATION_ACCESS_TOKEN')]) {
options = "--url https://releases.jfrog.io/artifactory --access-token=$JFROG_CLI_AUTOMATION_ACCESS_TOKEN"
downloadToolsCert()
print "Uploading version $version to Repo21"
uploadCli(architectures)
stage("Distribute executables") {
distributeToReleases("ecosystem-jfrog-cli", version, "cli-rbc-spec.json")
}
stage("Publish latest scripts") {
withCredentials([string(credentialsId: 'jfrog-cli-automation', variable: 'JFROG_CLI_AUTOMATION_ACCESS_TOKEN')]) {
options = "--url https://releases.jfrog.io/artifactory --access-token=$JFROG_CLI_AUTOMATION_ACCESS_TOKEN"
sh """#!/bin/bash
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/getCli.sh jfrog-cli/$identifier/scripts/ --flat $options --fail-no-op
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/install-cli.sh jfrog-cli/$identifier/scripts/ --flat $options --fail-no-op
"""
if (identifier == "v2-jf") {
sh """#!/bin/bash
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/getCli.sh jfrog-cli/$identifier/scripts/ --flat $options --fail-no-op
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/install-cli.sh jfrog-cli/$identifier/scripts/ --flat $options --fail-no-op
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/setup-cli.sh jfrog-cli/setup/scripts/getCli.sh --flat $options --fail-no-op
$builderPath rt cp "jfrog-cli/$identifier/$version/scripts/gitlab/(*)" "jfrog-cli/gitlab/{1}" $options --fail-no-op
"""
if (identifier == "v2-jf") {
sh """#!/bin/bash
$builderPath rt cp jfrog-cli/$identifier/$version/scripts/setup-cli.sh jfrog-cli/setup/scripts/getCli.sh --flat $options --fail-no-op
$builderPath rt cp "jfrog-cli/$identifier/$version/scripts/gitlab/(*)" "jfrog-cli/gitlab/{1}" $options --fail-no-op
"""
}
}
}
if (identifier == "v2") {
createTag()
}
}
if (identifier == "v2") {
createTag()
}

stage('Docker login') {
dockerLogin()
}

stage('Build and publish rpm and debian') {
buildRpmAndDeb(version, architectures)
}

stage('Npm publish') {
publishNpmPackage(jfrogCliRepoDir)
}

stage('Build and publish docker images') {
buildPublishDockerImages(version, jfrogCliRepoDir)
}

// Download cert files, to be used for signing the Windows executable, packaged by Chocolatey.
downloadToolsCert()
stage('Build and publish Chocolatey') {
publishChocoPackageWithRetries(version, jfrogCliRepoDir, architectures)
}
} finally {
cleanupRepo21()
Expand Down

0 comments on commit 8449ad5

Please sign in to comment.