Skip to content

Commit

Permalink
Merge branch 'master' into backup
Browse files Browse the repository at this point in the history
  • Loading branch information
LinuxSuRen committed Jun 15, 2022
2 parents 92e4afb + 0a0e878 commit 3cf15f6
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 24 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/backup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v3.2.0
with:
go-version: 1.16
id: go
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v3.0.2
- name: Upgrade upx
run: |
# try to fix https://github.com/jenkins-zh/jenkins-cli/issues/493
Expand All @@ -32,9 +32,9 @@ jobs:
BackupGit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: actions/checkout@v3.0.2
- name: backup
uses: jenkins-zh/git-backup-actions@v0.0.4
uses: jenkins-zh/git-backup-actions@v0.0.6
env:
GIT_DEPLOY_KEY: ${{ secrets.GIT_DEPLOY_KEY }}
TARGET_GIT: "git@gitee.com:jenkins-zh/jenkins-cli.git"
Expand All @@ -43,12 +43,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v3.2.0
with:
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.0.2
- name: Test
run: |
make test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
jenkins_version: [2.190.1, 2.190.2, 2.190.3, 2.204.1]
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v3.2.0
with:
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.0.2
- name: Build
env:
JENKINS_VERSION: ${{ matrix.jenkins_version }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v3.2.0
with:
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.0.2
- name: Upgrade upx
run: |
# try to fix https://github.com/jenkins-zh/jenkins-cli/issues/493
Expand Down Expand Up @@ -45,12 +45,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v3.2.0
with:
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.0.2
- name: Go-linter-1
uses: Jerome1337/golint-action@v1.0.2
with:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
GO111MODULE: on
steps:
- name: Checkout Source
uses: actions/checkout@v2
uses: actions/checkout@v3.0.2
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
Expand All @@ -103,12 +103,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Set up Go 1.16
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v3.2.0
with:
go-version: 1.16
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.0.2
- name: Test
run: |
make test
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release Drafter

on:
workflow_dispatch:
push:
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-20.04
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_SECRETS }}
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3.0.2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2.1.3
uses: actions/setup-go@v3.2.0
with:
go-version: 1.16.x
- name: Upgrade upx
Expand Down
2 changes: 1 addition & 1 deletion app/cmd/computer_launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ jcli agent launch agent-name --type jnlp`,
}

var f *os.File
if f, err = ioutil.TempFile("/tmp", "agent.jar"); err == nil {
if f, err = ioutil.TempFile("", "agent.jar"); err == nil {
computerLaunchOption.Output = f.Name()
agentURL := fmt.Sprintf("%s/jnlpJars/agent.jar", computerLaunchOption.ComputerClient.URL)
logger.Debug("start to download agent.jar", zap.String("url", agentURL))
Expand Down
69 changes: 65 additions & 4 deletions app/cmd/cwp.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ package cmd
import (
"encoding/xml"
"fmt"
"html/template"
"io/ioutil"
"os"
"path"

"github.com/jenkins-zh/jenkins-cli/app/cmd/common"
"github.com/jenkins-zh/jenkins-cli/app/i18n"
"github.com/jenkins-zh/jenkins-cli/util"
Expand All @@ -12,10 +17,6 @@ import (
"github.com/spf13/cobra"
"go.uber.org/zap"
"gopkg.in/yaml.v2"
"html/template"
"io/ioutil"
"os"
"path"
)

func init() {
Expand Down Expand Up @@ -174,6 +175,66 @@ func (o *CWPOptions) Run(cmd *cobra.Command, args []string) (err error) {
return
}

// RunWithoutProcessExits has the same logic with function Run and the difference between them is that RunWithoutProcessExits uses exec.Command() instead of syscall.Exec()
// which causes the process to exit without executing code after cwp.Run()
func (o *CWPOptions) RunWithoutProcessExits(cmd *cobra.Command, args []string) (err error) {
var ok bool
if ok, err = o.isPrintVersion(cmd); ok || err != nil {
return
}

localCWP := o.getLocalCWP()
_, err = os.Stat(localCWP)
if os.IsNotExist(err) {
if err = o.Download(); err != nil {
return
}
} else if err != nil {
return
}

_, err = util.LookPath("java", o.LookPathContext)
if err == nil {
cwpArgs := []string{"java"}
cwpArgs = append(cwpArgs, "-jar", localCWP)

if o.Demo {
cwpArgs = append(cwpArgs, "-demo")
}

if o.BatchMode {
cwpArgs = append(cwpArgs, "--batch-mode")
}

if o.InstallArtifacts {
cwpArgs = append(cwpArgs, "--installArtifacts")
}

configPath := o.ConfigPath
if configPath, err = RenderTemplate(o.ConfigPath, o.ValueSet); err != nil {
return
}
defer func() {
_ = os.RemoveAll(configPath)
}()
cwpArgs = append(cwpArgs, "-configPath", configPath)

if o.TmpDir != "" {
cwpArgs = append(cwpArgs, "-tmpDir", o.TmpDir)
}

if o.Version != "" {
cwpArgs = append(cwpArgs, "-version", o.Version)
}

// The strange cwpArgs here is because exec.Command() wants separate args
command := util.ExecCommand(nil, cwpArgs[0], cwpArgs[1], cwpArgs[2], cwpArgs[3], cwpArgs[4], cwpArgs[5], cwpArgs[6], cwpArgs[7], cwpArgs[8])
command.Stdout = os.Stdout
command.Run()
}
return
}

// RenderTemplate render a go template to a temporary file
func RenderTemplate(filepath string, values map[string]string) (result string, err error) {
var t *template.Template
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d h1:20cMwl2fHAzkJMEA+8J4JgqBQcQGzbisXo31MIeenXI=
golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
Expand Down Expand Up @@ -669,7 +668,6 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down

0 comments on commit 3cf15f6

Please sign in to comment.