Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into transfer-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi committed Jan 4, 2024
2 parents 8c699b8 + ab0b489 commit a2930aa
Show file tree
Hide file tree
Showing 19 changed files with 281 additions and 266 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
44 changes: 23 additions & 21 deletions artifactory/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import (
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/usersmanagement"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
containerutils "github.com/jfrog/jfrog-cli-core/v2/artifactory/utils/container"
"github.com/jfrog/jfrog-cli-core/v2/common/build"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/common/project"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common"
coreConfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
Expand Down Expand Up @@ -328,7 +330,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("mvnc", "rt", utils.Maven, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("mvnc", "rt", project.Maven, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -341,7 +343,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("mvn", utils.Maven, c, buildtools.MvnCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("mvn", project.Maven, c, buildtools.MvnCmd)
},
},
{
Expand All @@ -353,7 +355,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("gradlec", "rt", utils.Gradle, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("gradlec", "rt", project.Gradle, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -366,7 +368,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("gradle", utils.Gradle, c, buildtools.GradleCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("gradle", project.Gradle, c, buildtools.GradleCmd)
},
},
{
Expand Down Expand Up @@ -463,7 +465,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("npmc", "rt", utils.Npm, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("npmc", "rt", project.Npm, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -477,7 +479,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("npm install", utils.Npm, c, buildtools.NpmInstallCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("npm install", project.Npm, c, buildtools.NpmInstallCmd)
},
},
{
Expand All @@ -491,7 +493,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("npm ci", utils.Npm, c, buildtools.NpmCiCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("npm ci", project.Npm, c, buildtools.NpmCiCmd)
},
},
{
Expand All @@ -504,7 +506,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("npm p", utils.Npm, c, buildtools.NpmPublishCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("npm p", project.Npm, c, buildtools.NpmPublishCmd)
},
},
{
Expand All @@ -516,7 +518,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("yarnc", "rt", utils.Yarn, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("yarnc", "rt", project.Yarn, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -528,7 +530,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("yarn", utils.Yarn, c, buildtools.YarnCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("yarn", project.Yarn, c, buildtools.YarnCmd)
},
},
{
Expand All @@ -540,7 +542,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("nugetc", "rt", utils.Nuget, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("nugetc", "rt", project.Nuget, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -553,7 +555,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("nuget", utils.Nuget, c, buildtools.NugetCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("nuget", project.Nuget, c, buildtools.NugetCmd)
},
},
{
Expand All @@ -574,7 +576,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("dotnetc", "rt", utils.Dotnet, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("dotnetc", "rt", project.Dotnet, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -587,7 +589,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("dotnet", utils.Dotnet, c, buildtools.DotnetCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("dotnet", project.Dotnet, c, buildtools.DotnetCmd)
},
},
{
Expand All @@ -598,7 +600,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("go-config", "rt", utils.Go, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("go-config", "rt", project.Go, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -625,7 +627,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("go", utils.Go, c, buildtools.GoCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("go", project.Go, c, buildtools.GoCmd)
},
},
{
Expand Down Expand Up @@ -659,7 +661,7 @@ func GetCommands() []cli.Command {
ArgsUsage: common.CreateEnvVars(),
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunConfigCmdWithDeprecationWarning("pipc", "rt", utils.Pip, c, cliutils.CreateConfigCmd)
return cliutils.RunConfigCmdWithDeprecationWarning("pipc", "rt", project.Pip, c, cliutils.CreateConfigCmd)
},
},
{
Expand All @@ -673,7 +675,7 @@ func GetCommands() []cli.Command {
SkipFlagParsing: true,
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return cliutils.RunNativeCmdWithDeprecationWarning("pip install", utils.Pip, c, pipDeprecatedInstallCmd)
return cliutils.RunNativeCmdWithDeprecationWarning("pip install", project.Pip, c, pipDeprecatedInstallCmd)
},
},
{
Expand Down Expand Up @@ -1123,7 +1125,7 @@ func ocStartBuildCmd(c *cli.Context) error {
}

// Extract build configuration
filteredOcArgs, buildConfiguration, err := utils.ExtractBuildDetailsFromArgs(args)
filteredOcArgs, buildConfiguration, err := build.ExtractBuildDetailsFromArgs(args)
if err != nil {
return err
}
Expand Down Expand Up @@ -1855,10 +1857,10 @@ func pipDeprecatedInstallCmd(c *cli.Context) error {
}

// Get python configuration.
pythonConfig, err := utils.GetResolutionOnlyConfiguration(utils.Pip)
pythonConfig, err := project.GetResolutionOnlyConfiguration(project.Pip)
if err != nil {
return fmt.Errorf("error occurred while attempting to read %[1]s-configuration file: %[2]s\n"+
"Please run 'jf %[1]s-config' command prior to running 'jf %[1]s'", utils.Pip.String(), err.Error())
"Please run 'jf %[1]s-config' command prior to running 'jf %[1]s'", project.Pip.String(), err.Error())
}

// Set arg values.
Expand Down
13 changes: 8 additions & 5 deletions artifactory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"encoding/json"
"errors"
"fmt"
biutils "github.com/jfrog/build-info-go/utils"
"io"
"net"
"net/http"
Expand All @@ -24,15 +23,19 @@ import (
"testing"
"time"

biutils "github.com/jfrog/build-info-go/utils"

"github.com/buger/jsonparser"
gofrogio "github.com/jfrog/gofrog/io"
"github.com/jfrog/gofrog/version"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/commands/generic"
"github.com/jfrog/jfrog-cli-core/v2/artifactory/utils"
"github.com/jfrog/jfrog-cli-core/v2/common/commands"
"github.com/jfrog/jfrog-cli-core/v2/common/project"
"github.com/jfrog/jfrog-cli-core/v2/common/spec"
"github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
"github.com/jfrog/jfrog-cli-core/v2/utils/dependencies"
coretests "github.com/jfrog/jfrog-cli-core/v2/utils/tests"
"github.com/jfrog/jfrog-cli/inttestutils"
"github.com/jfrog/jfrog-cli/utils/cliutils"
Expand Down Expand Up @@ -4969,7 +4972,7 @@ func TestGetExtractorsRemoteDetails(t *testing.T) {
}

func validateExtractorRemoteDetails(t *testing.T, downloadPath, expectedRemotePath string) {
serverDetails, remotePath, err := utils.GetExtractorsRemoteDetails(downloadPath)
serverDetails, remotePath, err := dependencies.GetExtractorsRemoteDetails(downloadPath)
assert.NoError(t, err)
assert.Equal(t, expectedRemotePath, remotePath)
assert.False(t, os.Getenv(coreutils.DeprecatedExtractorsRemoteEnv) != "" && serverDetails == nil, "Expected a server to be returned")
Expand All @@ -4993,7 +4996,7 @@ func TestGetReleasesRemoteDetails(t *testing.T) {
}

func validateReleasesRemoteDetails(t *testing.T, downloadPath, expectedRemotePath string) {
serverDetails, remotePath, err := utils.GetExtractorsRemoteDetails(downloadPath)
serverDetails, remotePath, err := dependencies.GetExtractorsRemoteDetails(downloadPath)
assert.NoError(t, err)
assert.Equal(t, expectedRemotePath, remotePath)
assert.False(t, os.Getenv(coreutils.ReleasesRemoteEnv) != "" && serverDetails == nil, "Expected a server to be returned")
Expand Down Expand Up @@ -5658,7 +5661,7 @@ func testProjectInit(t *testing.T, projectExampleName string, technology coreuti
}

func validateProjectYamlFile(t *testing.T, projectDir, technology string) {
techConfig, err := utils.ReadConfigFile(filepath.Join(projectDir, ".jfrog", "projects", technology+".yaml"), utils.YAML)
techConfig, err := project.ReadConfigFile(filepath.Join(projectDir, ".jfrog", "projects", technology+".yaml"), project.YAML)
if assert.NoError(t, err) {
assert.Equal(t, technology, techConfig.GetString("type"))
assert.Equal(t, tests.ServerId, techConfig.GetString("resolver.serverId"))
Expand All @@ -5667,7 +5670,7 @@ func validateProjectYamlFile(t *testing.T, projectDir, technology string) {
}

func validateBuildYamlFile(t *testing.T, projectDir string) {
techConfig, err := utils.ReadConfigFile(filepath.Join(projectDir, ".jfrog", "projects", "build.yaml"), utils.YAML)
techConfig, err := project.ReadConfigFile(filepath.Join(projectDir, ".jfrog", "projects", "build.yaml"), project.YAML)
assert.NoError(t, err)
assert.Equal(t, "build", techConfig.GetString("type"))
assert.Equal(t, filepath.Base(projectDir+"/"), techConfig.GetString("name"))
Expand Down
Loading

0 comments on commit a2930aa

Please sign in to comment.