You've already forked sap-jenkins-library
							
							
				mirror of
				https://github.com/SAP/jenkins-library.git
				synced 2025-10-30 23:57:50 +02:00 
			
		
		
		
	feat(githubPublishRelease): make GitHub API timeout configurable (#5393)
Co-authored-by: Ashly Mathew <ashly.mathew@sap.com> Co-authored-by: phgermanov <phgermanov@gmail.com>
This commit is contained in:
		| @@ -7,6 +7,7 @@ import ( | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strings" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/SAP/jenkins-library/pkg/log" | ||||
| 	"github.com/SAP/jenkins-library/pkg/telemetry" | ||||
| @@ -30,9 +31,10 @@ type githubIssueClient interface { | ||||
|  | ||||
| func githubPublishRelease(config githubPublishReleaseOptions, telemetryData *telemetry.CustomData) { | ||||
| 	// TODO provide parameter for trusted certs | ||||
| 	ctx, client, err := piperGithub. | ||||
| 		NewClientBuilder(config.Token, config.APIURL). | ||||
| 		WithUploadURL(config.UploadURL).Build() | ||||
| 	ctx, client, err := piperGithub.NewClientBuilder(config.Token, config.APIURL). | ||||
| 		WithTimeout(time.Duration(config.GithubAPITimeout) * time.Second). | ||||
| 		WithUploadURL(config.UploadURL). | ||||
| 		Build() | ||||
| 	if err != nil { | ||||
| 		log.Entry().WithError(err).Fatal("Failed to get GitHub client.") | ||||
| 	} | ||||
|   | ||||
| @@ -20,6 +20,7 @@ type githubPublishReleaseOptions struct { | ||||
| 	AddClosedIssues       bool     `json:"addClosedIssues,omitempty"` | ||||
| 	AddDeltaToLastRelease bool     `json:"addDeltaToLastRelease,omitempty"` | ||||
| 	APIURL                string   `json:"apiUrl,omitempty"` | ||||
| 	GithubAPITimeout      int      `json:"githubApiTimeout,omitempty"` | ||||
| 	AssetPath             string   `json:"assetPath,omitempty"` | ||||
| 	AssetPathList         []string `json:"assetPathList,omitempty"` | ||||
| 	Commitish             string   `json:"commitish,omitempty"` | ||||
| @@ -169,6 +170,7 @@ func addGithubPublishReleaseFlags(cmd *cobra.Command, stepConfig *githubPublishR | ||||
| 	cmd.Flags().BoolVar(&stepConfig.AddClosedIssues, "addClosedIssues", false, "If set to `true`, closed issues and merged pull-requests since the last release will added below the `releaseBodyHeader`") | ||||
| 	cmd.Flags().BoolVar(&stepConfig.AddDeltaToLastRelease, "addDeltaToLastRelease", false, "If set to `true`, a link will be added to the release information that brings up all commits since the last release.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.APIURL, "apiUrl", `https://api.github.com`, "Set the GitHub API url.") | ||||
| 	cmd.Flags().IntVar(&stepConfig.GithubAPITimeout, "githubApiTimeout", 30, "Set HTTP timeout for GitHub API calls (in seconds)") | ||||
| 	cmd.Flags().StringVar(&stepConfig.AssetPath, "assetPath", os.Getenv("PIPER_assetPath"), "Path to a release asset which should be uploaded to the list of release assets.") | ||||
| 	cmd.Flags().StringSliceVar(&stepConfig.AssetPathList, "assetPathList", []string{}, "List of paths to a release asset which should be uploaded to the list of release assets.") | ||||
| 	cmd.Flags().StringVar(&stepConfig.Commitish, "commitish", `master`, "Target git commitish for the release") | ||||
| @@ -234,6 +236,15 @@ func githubPublishReleaseMetadata() config.StepData { | ||||
| 						Aliases:     []config.Alias{{Name: "githubApiUrl"}}, | ||||
| 						Default:     `https://api.github.com`, | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "githubApiTimeout", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
| 						Scope:       []string{"GENERAL", "PARAMETERS", "STAGES", "STEPS"}, | ||||
| 						Type:        "int", | ||||
| 						Mandatory:   false, | ||||
| 						Aliases:     []config.Alias{}, | ||||
| 						Default:     30, | ||||
| 					}, | ||||
| 					{ | ||||
| 						Name:        "assetPath", | ||||
| 						ResourceRef: []config.ResourceReference{}, | ||||
|   | ||||
| @@ -47,6 +47,15 @@ spec: | ||||
|         type: string | ||||
|         default: https://api.github.com | ||||
|         mandatory: true | ||||
|       - name: githubApiTimeout | ||||
|         description: Set HTTP timeout for GitHub API calls (in seconds) | ||||
|         scope: | ||||
|           - GENERAL | ||||
|           - PARAMETERS | ||||
|           - STAGES | ||||
|           - STEPS | ||||
|         type: int | ||||
|         default: 30 | ||||
|       - name: assetPath | ||||
|         description: Path to a release asset which should be uploaded to the list of release assets. | ||||
|         scope: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user