semaphoreci / cli Goto Github PK
View Code? Open in Web Editor NEWSemaphore 2.0 Command Line Interface
License: Apache License 2.0
Semaphore 2.0 Command Line Interface
License: Apache License 2.0
I'm wondering why we introduced sem stop pipeline
but not sem stop workflow
?
Workflow is the equivalent of "build" in S1, so that's what I have open in my web browser most of the time. Stopping the whole thing because I made a mistake in config file is exactly what I want, and I can easily copy the workflow ID from the address bar. Whereas I don't know how to get ID of the pipeline.
sem connect <url> <token>
should verify the validity of the token.
This will avoid issues like: "I connected to Semaphore, but then sem init failed with 401".
Apart from sem version
that works, sem delete project S2
, sem get projects
and sem get secrets
break:
The output of sem get secrets
is the following:
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x13a9fb1]
goroutine 1 [running]:
github.com/renderedtext/sem/cmd.RunGet(0x16d1840, 0xc420049110, 0x1, 0x1)
/home/runner/workspace/src/github.com/renderedtext/sem/cmd/get.go:30 +0x71
github.com/renderedtext/sem/cmd.glob..func6(0x16d1840, 0xc420049110, 0x1, 0x1)
/home/runner/workspace/src/github.com/renderedtext/sem/cmd/get.go:16 +0x49
github.com/spf13/cobra.(*Command).execute(0x16d1840, 0xc4200490d0, 0x1, 0x1, 0x16d1840, 0xc4200490d0)
/home/runner/workspace/src/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/spf13/cobra.(*Command).ExecuteC(0x16d0540, 0x16f79da, 0xc42012bf38, 0xc42012bf40)
/home/runner/workspace/src/github.com/spf13/cobra/command.go:852 +0x334
github.com/spf13/cobra.(*Command).Execute(0x16d0540, 0x0, 0x1)
/home/runner/workspace/src/github.com/spf13/cobra/command.go:800 +0x2b
github.com/renderedtext/sem/cmd.Execute()
/home/runner/workspace/src/github.com/renderedtext/sem/cmd/root.go:37 +0x31
main.main()
/home/runner/workspace/src/github.com/renderedtext/sem/main.go:6 +0x20```
git push
sem open
sem prints URL to semaphore pipeline for my push.
I was very frustrated to find that my $EDITOR or $VISUAL env var had no effect. please use standards.
Does this mean that project with same name is already added or something else is the issue?
✲ demo [1 hidden] (⎈ |s2prod:default) (master) sem init
error: repository is already initialized
A version should never be overridden.
Example:
Missing newline:
✲ sem apply -f /tmp/a.yml
Unknown resource kind ''%
Missing newline, and the message says 'created' instead of 'updated'
✲ sem apply -f /tmp/a.yml
Secret test10 created.%
Missing newlines:
✲ sem create -f /tmp/a.yml
Dashboard my-work-3 created.%
In Zsh, % signifies the missing newline.
Useful for scripting k8s test environments.
Currently, this happens:
error: unrecognized git remote format
$ sem version
v0.5.0-preview1
$ sem edit mySecrets
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/renderedtext/sem/cmd.RunEdit(0x16dffc0, 0xc42004b120, 0x1, 0x1)
/home/semaphore/go/src/github.com/renderedtext/sem/cmd/edit.go:26 +0xc4
github.com/renderedtext/sem/cmd.glob..func9(0x16dffc0, 0xc42004b120, 0x1, 0x1)
/home/semaphore/go/src/github.com/renderedtext/sem/cmd/edit.go:16 +0x49
github.com/spf13/cobra.(*Command).execute(0x16dffc0, 0xc42004b0e0, 0x1, 0x1, 0x16dffc0, 0xc42004b0e0)
/home/semaphore/go/src/github.com/spf13/cobra/command.go:766 +0x2c1
github.com/spf13/cobra.(*Command).ExecuteC(0x16e0480, 0xc42012bf30, 0xc42012bf38, 0x13b448e)
/home/semaphore/go/src/github.com/spf13/cobra/command.go:852 +0x334
github.com/spf13/cobra.(*Command).Execute(0x16e0480, 0x0, 0x16e06e0)
/home/semaphore/go/src/github.com/spf13/cobra/command.go:800 +0x2b
github.com/renderedtext/sem/cmd.Execute()
/home/semaphore/go/src/github.com/renderedtext/sem/cmd/root.go:37 +0x31
main.main()
/home/semaphore/go/src/github.com/renderedtext/sem/main.go:6 +0x20
$ sem create project aName
error: Failed to read from resource file.
panic: interface conversion: interface {} is nil, not string
goroutine 1 [running]:
github.com/semaphoreci/cli/cmd.glob..func7(0x1808be0, 0xc000092980, 0x2, 0x2)
/home/semaphore/cli/cmd/create.go:37 +0x83a
github.com/spf13/cobra.(*Command).execute(0x1808be0, 0xc000092900, 0x2, 0x2, 0x1808be0, 0xc000092900)
/home/semaphore/go/pkg/mod/github.com/spf13/[email protected]/command.go:766 +0x2cc
github.com/spf13/cobra.(*Command).ExecuteC(0x180bb60, 0x180bdc0, 0xc000111f50, 0x13c76ae)
/home/semaphore/go/pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2fd
github.com/spf13/cobra.(*Command).Execute(0x180bb60, 0x1005380, 0xc00006c058)
/home/semaphore/go/pkg/mod/github.com/spf13/[email protected]/command.go:800 +0x2b
github.com/semaphoreci/cli/cmd.Execute()
/home/semaphore/cli/cmd/root.go:37 +0x2d
main.main()
/home/semaphore/cli/main.go:6 +0x20
$ sem version
v0.7.5
Example: sem get projects <name>
Example:
✲ sem get secrets abc
apiVersion: ""
kind: ""
metadata:
name: abc
id: 297fcb54-0fd7-4ae0-b682-86b3eded6ded
create_time: "1536600478"
update_time: "1536918023"
data:
env_vars:
- name: A
value: B
files: []
Currently sem
does not add a project to Semaphore 2.0 if a .semaphore.yml
already exists in the directory.
On a Mac using HomeBrew:
$ sem version
v0.8.16
On a Linux using curl
:
$ sem version
v0.8.14
Otherwise, this will happen:
error: .semaphore/semaphore.yml is already present in the repository
$ cat /tmp/aFile
apiVersion: v1beta
kind: Secret
metadata:
name: my-secrets
id: 24d1932b-1c9b-4068-ac6a-1845a7816889
create_time: 1536679082
update_time: 1536755195
data:
- name: SECRET_ONE
- name: SECRET_TWO
files:
- path: file.txt
content: BbXQo=
Generates the following output:
$ sem apply -f /tmp/aFile
error: Failed to parse resource file.
panic: interface conversion: interface {} is nil, not string
goroutine 1 [running]:
github.com/semaphoreci/cli/cmd.RunApply(0x17f1f00, 0xc00000a8c0, 0x0, 0x2)
/home/semaphore/cli/cmd/apply.go:42 +0x32f
github.com/semaphoreci/cli/cmd.glob..func1(0x17f1f00, 0xc00000a8c0, 0x0, 0x2)
/home/semaphore/cli/cmd/apply.go:18 +0x49
github.com/spf13/cobra.(*Command).execute(0x17f1f00, 0xc00000a880, 0x2, 0x2, 0x17f1f00, 0xc00000a880)
/home/semaphore/go/pkg/mod/github.com/spf13/[email protected]/command.go:766 +0x2cc
github.com/spf13/cobra.(*Command).ExecuteC(0x17f1a40, 0x17f1ca0, 0xc0000fbf50, 0x13c163e)
/home/semaphore/go/pkg/mod/github.com/spf13/[email protected]/command.go:852 +0x2fd
github.com/spf13/cobra.(*Command).Execute(0x17f1a40, 0x1005380, 0xc00006c058)
/home/semaphore/go/pkg/mod/github.com/spf13/[email protected]/command.go:800 +0x2b
github.com/semaphoreci/cli/cmd.Execute()
/home/semaphore/cli/cmd/root.go:37 +0x2d
main.main()
/home/semaphore/cli/main.go:6 +0x20
$ sem create notif
$ sem create notification
$ sem create notifs
panic: runtime error: index out of range
...
This works as expected:
$ sem create notifications
error: Failed to read from resource file.
This also happens with other commands:
$ sem create jobs
$ sem create job
sem version
is v0.8.10
.
The Sem CLI can collide with the S1 sem CLI. To mitigate this, we should check the existence of a sem
command that is not in the expected path in the installation script, stop and ask the user to remove the old one.
based on glancing at this code:
https://github.com/semaphoreci/cli/blob/master/config/config.go#L51-L63
i would guess that there might be a --editor
flag. there doesn't seem to be or i'm using it wrong.
$ sem init
error: http status 422 with message "{"message":"project name \"project-name\" is already taken"}" received from upstream
so what to do next...?
Project is created. You can find it at https://tsoukalos.semaphoreci.com/projects/secretsInvalid.
To run your first pipeline execute:
git add .semaphore/semaphore.yml && git commit -m "First pipeline" && git push
However, https://tsoukalos.semaphoreci.com/projects/secretsInvalid
does not work.
$ ls -al
total 24
drwxr-xr-x 6 mtsouk staff 192 Jul 2 17:23 .
drwxr-xr-x@ 13 mtsouk staff 416 Jul 2 17:23 ..
drwxr-xr-x 13 mtsouk staff 416 Jul 2 17:23 .git
-rw-r--r-- 1 mtsouk staff 1014 Jul 2 17:23 .semaphore.yml
-rw-r--r-- 1 mtsouk staff 34 Jul 2 17:23 README.md
-rw-r--r-- 1 mtsouk staff 161 Jul 2 17:23 hw.go
$ sem init
error: repository is already initialized
$ sem get projects
NAME
anotherSecret
secrets
S1
The name of the project is S2
and was not added to Semaphore 2.0.
Motivated by the following question on support:
"Tried to do ssh to remote host but did not find my app folder at all."
One idea could be to display something like this when we jump into the box:
Here we could point out:
$ sem create job myjob --project S1 --command "ls -l"
Job '6ae18c12-7341-48d8-9283-5447992e77b6' created.
$ sem logs 6ae18c12-7341-48d8-9283-5447992e77b6
The sem logs
command returns no output and the job is shows as FAILED
in sem get jobs --all
.
Fails with:
error: Failed to open editor 'exec: "subl --wait": executable file not found in $PATH'
Which is obviously correct, there is no file called "subl --wait". --wait
is a flag, not part of the filename.
Example from kubernetes world:
semaphore@semaphore-vm:~/istio-playground$ kc edit virtualservice hello
error: virtualservices.networking.istio.io "hello" is invalid
A copy of your changes has been stored to "/tmp/kubectl-edit-7tb06.yaml"
error: Edit cancelled, no valid changes were saved.
If the response is a parsable JSON, extract message:
Current:
error: http status 400 with message "{"error":"Pattern /*/ is not a valid regex statement","message":"Pattern /*/ is not a valid regex statement","code":3}" received from upstream
Desired:
error: Pattern /*/ is not a valid regex statement
✲ sem init
Project is created. You can find it at https:///projects/yapi.
To run your first pipeline execute:
git add .semaphore.yml && git commit -m "First pipeline" && git push
✲ ~ sem debug project workflow-page --machine-type e1-standard-4 --duration 6h
error: http status 404 with message "{"message":"Not found"}" received from upstream
sem create dashboard product-team-master --projects "cli,ui,api-v1" --branch master
Creates a dashboard that display all pipelines from the master branch on projects a, b, and c.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.