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

Cxone release #12

Merged
merged 26 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
36e0462
Merge branch 'SAP:master' into cxone-release
thtri Apr 6, 2023
097cf87
Merge branch 'SAP:master' into cxone-dev
thtri Apr 6, 2023
99603cd
chore(tests): correct test assertions (#4276)
CCFenner Apr 11, 2023
f9617f5
feat(blackduck): Npm extra parameters (#4327)
akram8008 Apr 13, 2023
80e00dd
fix(checkmarxOne): test cases for pkg and reporting
thtri Apr 14, 2023
099c68f
Merge pull request #5 from hubadr/cxone-dev-thanh2
thtri Apr 14, 2023
cff4791
Merge pull request #6 from hubadr/cxone-dev
thtri Apr 14, 2023
91882f1
Merge branch 'master' into cxone-release
thtri Apr 14, 2023
3a79292
fix(checkmarxOne):fix formatting
thtri Apr 14, 2023
f8cf10e
Merge pull request #7 from hubadr/cxone-dev-thanh2
thtri Apr 14, 2023
82d2f65
Merge pull request #8 from hubadr/cxone-dev
thtri Apr 14, 2023
e3935ca
feat(vault): Vault secret rotation for GH Actions (#4280)
jliempt Apr 17, 2023
b59ca48
Merge branch 'master' into cxone-release
thtri Apr 17, 2023
65b3ca2
Merge branch 'SAP:master' into cxone-dev-thanh2
thtri Apr 17, 2023
4f4e667
add ascAppUpload step (#4286)
Mau04 Apr 18, 2023
5d8e89b
feat(cnbBuild): use SHA256 hashed values for redacted telemetry prope…
pbusko Apr 18, 2023
5294495
docs: add ascAppUpload (#4330)
Mau04 Apr 18, 2023
6624703
feat(checkmarxone): update interface with missing method
thtri Apr 21, 2023
35754ab
feat(checkmarxone):change runStep signature to be able to inject depe…
thtri Apr 21, 2023
08147e1
feat(checkmarxone): add tests for step (wip)
thtri Apr 21, 2023
389802a
Merge remote-tracking branch 'refs/remotes/origin/cxone-dev-thanh2' i…
thtri Apr 21, 2023
d331d07
Merge branch 'SAP:master' into cxone-dev
thtri Apr 21, 2023
e2b0e00
Merge branch 'SAP:master' into cxone-release
thtri Apr 21, 2023
7248987
Merge pull request #10 from hubadr/cxone-dev-thanh2
thtri Apr 21, 2023
a25958f
Merge pull request #11 from hubadr/cxone-dev
thtri Apr 21, 2023
2b8bf5a
Merge branch 'cxone-dev-michael' into cxone-release
michaelkubiaczyk Apr 24, 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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ AbapAddonAssemblyKit* @SAP/jenkins-library-abap
abapEnvironment* @SAP/jenkins-library-abap
AbapEnvironment* @SAP/jenkins-library-abap

ascAppUpload* @Mau04 @inf2381
AscAppUpload* @Mau04 @inf2381

#####################
# Integration tests #
Expand Down
106 changes: 106 additions & 0 deletions cmd/ascAppUpload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package cmd

import (
"github.com/SAP/jenkins-library/pkg/asc"
"github.com/SAP/jenkins-library/pkg/command"
piperHttp "github.com/SAP/jenkins-library/pkg/http"
"github.com/SAP/jenkins-library/pkg/log"
"github.com/SAP/jenkins-library/pkg/piperutils"
"github.com/SAP/jenkins-library/pkg/telemetry"
"github.com/pkg/errors"
)

type ascAppUploadUtils interface {
command.ExecRunner
}

type ascAppUploadUtilsBundle struct {
*command.Command
*piperutils.Files
}

func newAscAppUploadUtils() ascAppUploadUtils {
utils := ascAppUploadUtilsBundle{
Command: &command.Command{},
Files: &piperutils.Files{},
}
// Reroute command output to logging framework
utils.Stdout(log.Writer())
utils.Stderr(log.Writer())
return &utils
}

func ascAppUpload(config ascAppUploadOptions, telemetryData *telemetry.CustomData) {
utils := newAscAppUploadUtils()
client := &piperHttp.Client{}

ascClient, err := asc.NewSystemInstance(client, config.ServerURL, config.AppToken)
if err != nil {
log.Entry().WithError(err).Fatalf("Failed to create ASC client talking to URL %v", config.ServerURL)
} else {
err = runAscAppUpload(&config, telemetryData, utils, ascClient)
}

if err != nil {
log.Entry().WithError(err).Fatal("step execution failed")
}
}

func runAscAppUpload(config *ascAppUploadOptions, telemetryData *telemetry.CustomData, utils ascAppUploadUtils, ascClient asc.System) error {

if len(config.JamfTargetSystem) == 0 {
return errors.Errorf("jamfTargetSystem must be set")
}

log.Entry().Infof("Collect data to create new release in ASC")

app, err := ascClient.GetAppById(config.AppID)
if err != nil {
log.SetErrorCategory(log.ErrorConfiguration)
return errors.Wrapf(err, "failed to get app information")
}

log.Entry().Debugf("Found App with name %v", app.AppName)

log.Entry().Infof("Create release for %v in ASC (AppID %v)", app.AppName, app.AppId)

releaseResponse, err := ascClient.CreateRelease(app.AppId, config.ReleaseAppVersion, config.ReleaseDescription, config.ReleaseDate, config.ReleaseVisible)

if err != nil {
log.SetErrorCategory(log.ErrorService)
return errors.Wrapf(err, "failed to create release")
}

if releaseResponse.Status != "success" {
log.SetErrorCategory(log.ErrorService)
return errors.New(releaseResponse.Message)
}

log.Entry().Infof("Collect data to upload app to ASC & Jamf")

jamfAppInformationResponse, err := ascClient.GetJamfAppInfo(app.BundleId, config.JamfTargetSystem)
if err != nil {
log.SetErrorCategory(log.ErrorService)
return errors.Wrapf(err, "failed to get jamf app info")
}

jamfAppId := jamfAppInformationResponse.MobileDeviceApplication.General.Id

if jamfAppId == 0 {
return errors.Errorf("failed to get jamf app id")
}

log.Entry().Debugf("Got Jamf info for app %v, jamfId: %v", app.AppName, jamfAppId)

log.Entry().Infof("Upload ipa %v to ASC & Jamf", config.FilePath)

err = ascClient.UploadIpa(config.FilePath, jamfAppId, config.JamfTargetSystem, app.BundleId, releaseResponse.Data)
if err != nil {
log.SetErrorCategory(log.ErrorService)
return errors.Wrapf(err, "failed to upload ipa")
}

log.Entry().Infof("Successfully uploaded %v to ASC (AppId %v) & Jamf (Id %v)", config.FilePath, app.AppId, jamfAppId)

return nil
}
253 changes: 253 additions & 0 deletions cmd/ascAppUpload_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions cmd/ascAppUpload_generated_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestAscAppUploadCommand(t *testing.T) {
t.Parallel()

testCmd := AscAppUploadCommand()

// only high level testing performed - details are tested in step generation procedure
assert.Equal(t, "ascAppUpload", testCmd.Use, "command name incorrect")

}
Loading