Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New JFrog Pipelines commands #1766

Merged
merged 25 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5ef67e7
Added pipelines run status and trigger run
bhanurp Nov 23, 2022
aea58a8
Moved pipelines commands to jfrog-cli-core
bhanurp Nov 24, 2022
2d21db6
Updated with multi branch details
bhanurp Dec 14, 2022
7271a60
Updated command pipelines short hand
bhanurp Dec 20, 2022
52a6ce1
Updated command pipelines short hand
bhanurp Dec 20, 2022
0a4f69c
Fixed possible review comments
bhanurp Dec 22, 2022
2abcb6d
Updated pipelines command
bhanurp Jan 1, 2023
9ddec8a
Updated cli core revision
bhanurp Jan 1, 2023
36c12ff
Merge branch 'dev' into v2
bhanurp Jan 2, 2023
7ed4c6b
Correct dependency conflict
bhanurp Jan 2, 2023
3e407b4
Updated logs and comments starting letter to upper case
bhanurp Jan 4, 2023
eb3168c
Updated pipelines command to pl
bhanurp Jan 4, 2023
b7af659
Updated with camel case
bhanurp Jan 4, 2023
6e1de6e
Removed notification feature
bhanurp Jan 5, 2023
72c4228
Updated pielines cli with docs
bhanurp Jan 13, 2023
37d2cc5
Updated to use commands exec
bhanurp Jan 14, 2023
2dc02ef
Updated comments to start with capital letter
bhanurp Jan 14, 2023
237b8cb
Added pipeline commands
bhanurp Jan 17, 2023
7e5d9d1
Updated pipelines commands arguments help doc
bhanurp Jan 17, 2023
2f5de1a
Updated pipelines commands arguments help doc
bhanurp Jan 17, 2023
31a0d2a
Opted to use err for error variable for possible redeclaration
bhanurp Jan 19, 2023
9cdf65e
Merge branch 'dev' into v2
bhanurp Jan 24, 2023
b7f2751
Relative changes to cli-core
bhanurp Jan 24, 2023
d8324ad
Refactored pipeline commands to cli
bhanurp Jan 26, 2023
31851a2
Changed sync status command to sync-status
bhanurp Jan 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func TestPushFatManifestImage(t *testing.T) {
user := *tests.JfrogUser
if *tests.JfrogAccessToken != "" {
user = auth.ExtractUsernameFromAccessToken(*tests.JfrogAccessToken)
require.NoError(t, err)
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
password = *tests.JfrogAccessToken
}
assert.NoError(t, testContainer.Exec(
Expand Down
13 changes: 10 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ require (
github.com/emirpasic/gods v1.12.0 // indirect
github.com/forPelevin/gomoji v1.1.6 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
github.com/gocarina/gocsv v0.0.0-20220823132111-71f3a5cb2654 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand Down Expand Up @@ -79,6 +82,7 @@ require (
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
Expand All @@ -100,6 +104,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
github.com/ulikunitz/xz v0.5.9 // indirect
github.com/xanzy/ssh-agent v0.3.3-0.20220920102508-0fa644ba07f4 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
Expand All @@ -121,10 +126,12 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.2-0.20221107114147-4a1ad939c80e
// replace github.com/jfrog/build-info-go => github.com/jfrog/build-info-go v1.8.1-0.20221031115821-41443331f630

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.24.6-0.20221227065543-64d39165803a
replace github.com/jfrog/jfrog-cli-core/v2 => github.com/bhanurp/jfrog-cli-core/v2 v2.24.4-0.20230104123943-361ed92a7eee

replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.26.1-0.20221228094004-365894ac6254
// replace github.com/jfrog/jfrog-cli-core/v2 => github.com/jfrog/jfrog-cli-core/v2 v2.26.1-0.20221228094004-365894ac6254

// replace github.com/jfrog/gofrog => github.com/jfrog/gofrog v1.2.5-0.20221107113836-a4c9225c690e

replace github.com/jfrog/jfrog-client-go => github.com/jfrog/jfrog-client-go v1.24.6-0.20221229104544-1cf7ece4449c
19 changes: 15 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bhanurp/jfrog-cli-core/v2 v2.24.4-0.20230104123943-361ed92a7eee h1:gSaTEGsok+aiOoT2Nmkd8csd9qJNE/ZRgZafGB0BE9w=
github.com/bhanurp/jfrog-cli-core/v2 v2.24.4-0.20230104123943-361ed92a7eee/go.mod h1:6E4CcqU/B1N22j8hZtpIfppyJtfJ1PH2co8QqXyk7FE=
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
Expand Down Expand Up @@ -354,6 +356,8 @@ github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwV
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
github.com/garyburd/redigo v0.0.0-20150301180006-535138d7bcd7/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05/YaO1SY=
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6 h1:jFEK/SA/7E8lg9T33+y8D4Z0I782+bbiEjmyyklRzRQ=
github.com/gen2brain/beeep v0.0.0-20220909211152-5a9ec94374f6/go.mod h1:/WeFVhhxMOGypVKS0w8DUJxUBbHypnWkUVnW7p5c9Pw=
github.com/ghodss/yaml v0.0.0-20150909031657-73d445a93680/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
Expand Down Expand Up @@ -391,6 +395,8 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE=
github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
github.com/gocarina/gocsv v0.0.0-20220823132111-71f3a5cb2654 h1:Sk9pCo4kBYVtDKJvh66DuvFDDNMH1CwnakCKMB/2A1U=
github.com/gocarina/gocsv v0.0.0-20220823132111-71f3a5cb2654/go.mod h1:5YoVOkjYAQumqlV356Hj3xeYh4BdZuLE0/nRkf2NKkI=
github.com/godbus/dbus v0.0.0-20151105175453-c7fdd8b5cd55/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
Expand All @@ -399,6 +405,8 @@ github.com/godbus/dbus v0.0.0-20190422162347-ade71ed3457e/go.mod h1:bBOAhwG1umN6
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU=
github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down Expand Up @@ -531,10 +539,8 @@ github.com/jfrog/build-info-go v1.8.4 h1:OisVjARmaXzXV9IuGvNJzB0XL8a6RVSrR2/zOsR
github.com/jfrog/build-info-go v1.8.4/go.mod h1:iSTj26qEX3eUtyAGMH0qKsW4WJT+MceYxLWP9FfiAq4=
github.com/jfrog/gofrog v1.2.5 h1:jCgJC0iGQ8bU7jCC+YEFJTNINyngApIrhd8BjZAVRIE=
github.com/jfrog/gofrog v1.2.5/go.mod h1:o00tSRff6IapTgaCMuX1Cs9MH08Y1JqnsKgRtx91Gc4=
github.com/jfrog/jfrog-cli-core/v2 v2.26.1-0.20221228094004-365894ac6254 h1:QAqiiiDU2hkAMIFaQCegIIJFjbV8Ga3anV4UJAB+ZYQ=
github.com/jfrog/jfrog-cli-core/v2 v2.26.1-0.20221228094004-365894ac6254/go.mod h1:l0yqFZ91rgaip+naVdcPEmtz0TmndUZy7KjMlj0zR2k=
github.com/jfrog/jfrog-client-go v1.24.6-0.20221227065543-64d39165803a h1:9ni92q7WcMDTGtvH/GpQ93+6k16qWticYwKvXw7HLuM=
github.com/jfrog/jfrog-client-go v1.24.6-0.20221227065543-64d39165803a/go.mod h1:jCif5JAnF3RZ+ldzJ+0jX1OCcrXzJVjWHENVGyiy6nI=
github.com/jfrog/jfrog-client-go v1.24.6-0.20221229104544-1cf7ece4449c h1:1ZS7CWw0/W5SKyjbQm5ZhBzMG2slGqMqtiU8t9tEEJA=
github.com/jfrog/jfrog-client-go v1.24.6-0.20221229104544-1cf7ece4449c/go.mod h1:jCif5JAnF3RZ+ldzJ+0jX1OCcrXzJVjWHENVGyiy6nI=
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
Expand Down Expand Up @@ -651,6 +657,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/ncw/swift v1.0.47/go.mod h1:23YIA4yWVnGwv2dQlN4bB7egfYX6YLn0Yo/S6zZO/ZM=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/nwaples/rardecode v1.1.0 h1:vSxaY8vQhOcVr4mm5e8XllHWTiM4JF507A0Katqw7MQ=
github.com/nwaples/rardecode v1.1.0/go.mod h1:5DzqNKiOdpKKBH87u8VlvAnPZMXcGRhxWkRpHbbfGS0=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down Expand Up @@ -832,6 +840,8 @@ github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t
github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20180916011248-d98352740cb2/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww=
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk=
github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
github.com/tchap/go-patricia v2.2.6+incompatible/go.mod h1:bmLyhP68RS6kStMGxByiQ23RP/odRBOTVjwp2cDyi6I=
github.com/testcontainers/testcontainers-go v0.15.0 h1:3Ex7PUGFv0b2bBsdOv6R42+SK2qoZnWBd21LvZYhUtQ=
github.com/testcontainers/testcontainers-go v0.15.0/go.mod h1:PkohMRH2X8Hib0IWtifVexDfLPVT+tb5E9hsf7cW12w=
Expand Down Expand Up @@ -1122,6 +1132,7 @@ golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/jfrog/jfrog-cli/general/envsetup"
"github.com/jfrog/jfrog-cli/general/project"
"github.com/jfrog/jfrog-cli/missioncontrol"
"github.com/jfrog/jfrog-cli/pipelines"
"github.com/jfrog/jfrog-cli/plugins"
"github.com/jfrog/jfrog-cli/plugins/utils"
"github.com/jfrog/jfrog-cli/scan"
Expand Down Expand Up @@ -247,6 +248,12 @@ func getCommands() []cli.Command {
fmt.Println(common.GetGlobalEnvVars())
},
},
{
Name: cliutils.CmdPipelines,
Usage: "pipelines commands for source validation, run and run status",
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
Subcommands: pipelines.GetCommands(),
Category: otherCategory,
},
}
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
allCommands := append(cliNameSpaces, utils.GetPlugins()...)
allCommands = append(allCommands, scan.GetCommands()...)
Expand Down
62 changes: 62 additions & 0 deletions pipelines/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package pipelines

import (
corecommon "github.com/jfrog/jfrog-cli-core/v2/docs/common"
"github.com/jfrog/jfrog-cli/utils/cliutils"
"github.com/urfave/cli"
)

func GetCommands() []cli.Command {
return cliutils.GetSortedCommands(cli.CommandsByName{
{
Name: "status",
Flags: cliutils.GetCommandFlags(cliutils.Status),
Aliases: []string{"s"},
Description: "Get status of latest run of pipeline",
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return fetchLatestPipelineRunStatus(c)
},
},
{
Name: "trigger",
Flags: cliutils.GetCommandFlags(cliutils.Trigger),
Aliases: []string{"t"},
Description: "Trigger a run for given pipeline and branch",
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return triggerNewRun(c)
},
},
{
Name: "version",
Flags: cliutils.GetCommandFlags(cliutils.Version),
Aliases: []string{"v"},
Description: "Get pipeline version on server",
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return getVersion(c)
},
},
{
Name: "sync",
Flags: cliutils.GetCommandFlags(cliutils.Sync),
Aliases: []string{"sy"},
Description: "Trigger pipeline resource sync",
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return syncPipelineResources(c)
},
},
{
Name: "syncstatus",
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
Flags: cliutils.GetCommandFlags(cliutils.SyncStatus),
Aliases: []string{"ss"},
Description: "Get pipeline resource sync status",
BashComplete: corecommon.CreateBashCompletionFunc(),
Action: func(c *cli.Context) error {
return getSyncPipelineResourcesStatus(c)
},
},
})
}
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
44 changes: 44 additions & 0 deletions pipelines/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package pipelines

import (
utilsconfig "github.com/jfrog/jfrog-cli-core/v2/utils/config"
"github.com/jfrog/jfrog-client-go/utils/errorutils"
clientlog "github.com/jfrog/jfrog-client-go/utils/log"
"github.com/urfave/cli"
"strconv"
)

// getServiceDetails returns server details based on serverID
// if serverID is empty returns default config otherwise error
func getServiceDetails(serverID string) (*utilsconfig.ServerDetails, error) {
if serverID == "" {
conf, err := utilsconfig.GetDefaultServerConf()
if err != nil {
clientlog.Error("Unable to find server configuration exiting")
return nil, errorutils.CheckError(err)
}
serverID = conf.ServerId
}
serviceDetails, err := utilsconfig.GetSpecificConfig(serverID, false, false)
if err != nil {
clientlog.Error(err)
return nil, errorutils.CheckError(err)
}
return serviceDetails, err
}
bhanurp marked this conversation as resolved.
Show resolved Hide resolved

// getMultiBranch parses multibranch flag to bool
func getMultiBranch(c *cli.Context) bool {
multiBranch := c.String("multiBranch")
if multiBranch == "" {
return true
} else {
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
multiBranch, err := strconv.ParseBool(multiBranch)
if err != nil {
clientlog.Warn("MultiBranch flag can parse these values: [1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False]")
clientlog.Warn("Setting multiBranch to true")
return true
}
return multiBranch
}
}
39 changes: 39 additions & 0 deletions pipelines/runstatus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package pipelines

import (
status "github.com/jfrog/jfrog-cli-core/v2/pipelines/commands"
"github.com/jfrog/jfrog-cli-core/v2/utils/coreutils"
clientlog "github.com/jfrog/jfrog-client-go/utils/log"
"github.com/urfave/cli"
)

// fetchLatestPipelineRunStatus fetch pipeline run status based on flags
// supplied
func fetchLatestPipelineRunStatus(c *cli.Context) error {
clientlog.Info(coreutils.PrintTitle("🐸🐸🐸 Fetching pipeline run status"))

// read flags for status command
serverID := c.String("server-id")
pipName := c.String("name")
notify := c.Bool("monitor")
branch := c.String("branch")
multiBranch := getMultiBranch(c)
serviceDetails, servErr := getServiceDetails(serverID)
if servErr != nil {
return servErr
}
statusCommand := status.NewStatusCommand()
statusCommand.SetBranch(branch).
SetPipeline(pipName).
SetNotify(notify).
SetMultiBranch(multiBranch)

// set server details
statusCommand.SetServerDetails(serviceDetails)
op, runErr := statusCommand.Run()
if runErr != nil {
return runErr
}
clientlog.Output(op)
return nil
}
56 changes: 56 additions & 0 deletions pipelines/sync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package pipelines

import (
syncPipeRes "github.com/jfrog/jfrog-cli-core/v2/pipelines/commands"
clientlog "github.com/jfrog/jfrog-client-go/utils/log"
"github.com/urfave/cli"
)

// syncPipelineResources sync pipelines resource
func syncPipelineResources(c *cli.Context) error {
branch := c.String("branch")
repository := c.String("repository")
serverID := c.String("server-id")
clientlog.Info("🐸🐸🐸 Triggering pipeline sync on repository ", repository, "branch", branch)
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
serviceDetails, servErr := getServiceDetails(serverID)
if servErr != nil {
return servErr
}

// create new sync command and add filters
syncCommand := syncPipeRes.NewSyncCommand()
syncCommand.SetBranch(branch)
syncCommand.SetRepositoryFullName(repository)
syncCommand.SetServerDetails(serviceDetails)
err := syncCommand.Run()
if err != nil {
return err
}
return nil
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
}

// getSyncPipelineResourcesStatus fetch sync status for a given repository path and branch name
func getSyncPipelineResourcesStatus(c *cli.Context) error {
branch := c.String("branch")
repository := c.String("repository")
serverID := c.String("server-id")
clientlog.Info("🐸🐸🐸 Fetching pipeline sync status on repository ", repository, "branch", branch)

// fetch service details for authentication
serviceDetails, servErr := getServiceDetails(serverID)
if servErr != nil {
return servErr
}

// create sync status command and add filter params
syncStatusCommand := syncPipeRes.NewSyncStatusCommand()
syncStatusCommand.SetBranch(branch)
syncStatusCommand.SetRepoPath(repository)
syncStatusCommand.SetServerDetails(serviceDetails)
statusOutput, err := syncStatusCommand.Run()
if err != nil {
return err
}
clientlog.Output(statusOutput)
return nil
}
33 changes: 33 additions & 0 deletions pipelines/systeminfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package pipelines

import (
status "github.com/jfrog/jfrog-cli-core/v2/pipelines/commands"
clientlog "github.com/jfrog/jfrog-client-go/utils/log"
"github.com/urfave/cli"
)

// getVersion version command handler
func getVersion(c *cli.Context) error {
err := writePipelinesVersion(c)
if err != nil {
return err
}
return nil
bhanurp marked this conversation as resolved.
Show resolved Hide resolved
}

// writePipelinesVersion writes pipelines server version to console
func writePipelinesVersion(c *cli.Context) error {
serverID := c.String("server-id")
serviceDetails, servErr := getServiceDetails(serverID)
if servErr != nil {
return servErr
}
versionCommand := status.NewVersionCommand()
versionCommand.SetServerDetails(serviceDetails)
version, runErr := versionCommand.Run()
if runErr != nil {
return runErr
}
clientlog.Output("Pipelines Server Version: ", version)
return nil
}
Loading