mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-05 15:15:44 +02:00
fix code climate issues II (#715)
* fix code climate issues * fix code climate issues * fix code climate issues
This commit is contained in:
parent
cf08f3c7c8
commit
41ee87d147
@ -71,8 +71,7 @@ To setup the shared library, you need to perform the following steps:
|
||||
|
||||
1. Login to your Jenkins instance with administration privileges.
|
||||
1. Open the system configuration page (*Manage Jenkins > Configure System*).
|
||||
1. Scroll down to section *Global Pipeline Libraries* and add a new Library by
|
||||
clicking the *Add* button.
|
||||
1. Scroll down to section *Global Pipeline Libraries* and add a new Library by clicking the *Add* button.
|
||||
1. set *Library Name* to `piper-lib-os`
|
||||
1. set *Default Version* to the branch or tag you want to consume (e.g. `master` or `v0.1`)
|
||||
1. set *Retrieval Method* to `Modern SCM`
|
||||
@ -102,6 +101,7 @@ Feel free to open new issues for feature requests, bugs or general feedback on
|
||||
the [GitHub issues page of this project][piper-library-issues].
|
||||
|
||||
Register to our [google group][google-group] in order to get updates or for asking questions.
|
||||
|
||||
# Contributing
|
||||
|
||||
Read and understand our [contribution guidelines][piper-library-contribution]
|
||||
|
@ -11,10 +11,10 @@ Your configuration inherits from the default configuration located at [https://g
|
||||
Configuration of the Piper steps as well the Piper templates can be done in a hierarchical manner.
|
||||
|
||||
1. Directly passed step parameters will always take precedence over other configuration values and defaults
|
||||
2. Stage configuration parameters define a Jenkins pipeline stage dependent set of parameters (e.g. deployment options for the `Acceptance` stage)
|
||||
3. Step configuration defines how steps behave in general (e.g. step `cloudFoundryDeploy`)
|
||||
4. General configuration parameters define parameters which are available across step boundaries
|
||||
5. Default configuration comes with the Piper library and is always available
|
||||
1. Stage configuration parameters define a Jenkins pipeline stage dependent set of parameters (e.g. deployment options for the `Acceptance` stage)
|
||||
1. Step configuration defines how steps behave in general (e.g. step `cloudFoundryDeploy`)
|
||||
1. General configuration parameters define parameters which are available across step boundaries
|
||||
1. Default configuration comes with the Piper library and is always available
|
||||
|
||||

|
||||
|
||||
|
@ -4,4 +4,4 @@
|
||||
|
||||
.md-typeset a:not(.headerlink):hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
@ -33,10 +33,10 @@ The basic workflow is as follows:
|
||||
|
||||
**Note:** The blank line between message header and message description is mandatory.
|
||||
|
||||
2. To communicate with SAP Solution Manager, the pipeline uses credentials that must be stored on Jenkins using the credential ID `CM`. For more information, see [checkChangeInDevelopment](https://sap.github.io/jenkins-library/steps/checkChangeInDevelopment/).
|
||||
3. The required transport request is created on the fly. **Note:** The change document can contain various components (for example, UI and backend components).
|
||||
4. The changes of your development team trigger the Jenkins pipeline. It builds and validates the changes and attaches them to the respective transport request.
|
||||
5. As soon as the development process is completed, the change document in SAP Solution Manager can be set to status `to be tested` and all components can be transported to the test system.
|
||||
1. To communicate with SAP Solution Manager, the pipeline uses credentials that must be stored on Jenkins using the credential ID `CM`. For more information, see [checkChangeInDevelopment](https://sap.github.io/jenkins-library/steps/checkChangeInDevelopment/).
|
||||
1. The required transport request is created on the fly. **Note:** The change document can contain various components (for example, UI and backend components).
|
||||
1. The changes of your development team trigger the Jenkins pipeline. It builds and validates the changes and attaches them to the respective transport request.
|
||||
1. As soon as the development process is completed, the change document in SAP Solution Manager can be set to status `to be tested` and all components can be transported to the test system.
|
||||
|
||||

|
||||
###### Hybrid Application Development Workflow
|
||||
|
@ -32,8 +32,7 @@ resource in an custom shared library.
|
||||
|
||||
// inside the shared lib denoted by 'foo' the additional configuration file
|
||||
// needs to be located under 'resources' ('resoures/myConfig.yml')
|
||||
prepareDefaultValues script: this,
|
||||
customDefaults: 'myConfig.yml'
|
||||
prepareDefaultValues script: this, customDefaults: 'myConfig.yml'
|
||||
```
|
||||
|
||||
Example content of `'resources/myConfig.yml'` in branch `'master'` of the repository denoted by
|
||||
@ -79,11 +78,13 @@ The parameters can also be provided when the step is invoked:
|
||||
// explict endpoint provided, we search for changeDocumentId
|
||||
// starting at the previous commit (HEAD~1) rather than on
|
||||
// 'origin/master' (the default).
|
||||
checkChangeInDevelopment script:this
|
||||
changeManagement: [
|
||||
endpoint: 'https:example.org/cm'
|
||||
git: [
|
||||
from: 'HEAD~1'
|
||||
]
|
||||
]
|
||||
checkChangeInDevelopment(
|
||||
script: this
|
||||
changeManagement: [
|
||||
endpoint: 'https:example.org/cm'
|
||||
git: [
|
||||
from: 'HEAD~1'
|
||||
]
|
||||
]
|
||||
)
|
||||
```
|
||||
|
@ -43,7 +43,7 @@ Once you have started both docker containers and Influx and Grafana are running
|
||||
To setup your Jenkins you need to do two configuration steps:
|
||||
|
||||
1. Configure Jenkins (via Manage Jenkins)
|
||||
2. Adapt pipeline configuration
|
||||
1. Adapt pipeline configuration
|
||||
|
||||
### Configure Jenkins
|
||||
|
||||
|
@ -10,7 +10,7 @@ Kaniko expects a Docker `config.json` file containing the credential information
|
||||
You can create it like explained in the Docker Success Center in the articale about [How to generate a new auth in the config.json file](https://success.docker.com/article/generate-new-auth-in-config-json-file).
|
||||
|
||||
Please copy this file and upload it to your Jenkins for example<br />
|
||||
via _Jenkins_ -> _Credentials_ -> _System_ -> _Global credentials (unrestricted)_ -> _ Add Credentials_ ->
|
||||
via _Jenkins_ -> _Credentials_ -> _System_ -> _Global credentials (unrestricted)_ -> _Add Credentials_ ->
|
||||
|
||||
* Kind: _Secret file_
|
||||
* File: upload your `config.json` file
|
||||
|
@ -23,8 +23,7 @@ resource in an custom shared library.
|
||||
|
||||
// inside the shared lib denoted by 'foo' the additional configuration file
|
||||
// needs to be located under 'resources' ('resoures/myConfig.yml')
|
||||
prepareDefaultValues script: this,
|
||||
customDefaults: 'myConfig.yml'
|
||||
prepareDefaultValues script: this, customDefaults: 'myConfig.yml'
|
||||
```
|
||||
|
||||
Example content of `'resources/myConfig.yml'` in branch `'master'` of the repository denoted by
|
||||
|
@ -74,21 +74,25 @@ The parameters can also be provided when the step is invoked. For examples see b
|
||||
|
||||
```groovy
|
||||
// SOLMAN
|
||||
transportRequestUploadFile script:this,
|
||||
changeDocumentId: '001', // typically provided via git commit history
|
||||
transportRequestId: '001', // typically provided via git commit history
|
||||
applicationId: '001',
|
||||
filePath: '/path',
|
||||
changeManagement:[
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
transportRequestUploadFile(
|
||||
script: this,
|
||||
changeDocumentId: '001', // typically provided via git commit history
|
||||
transportRequestId: '001', // typically provided via git commit history
|
||||
applicationId: '001',
|
||||
filePath: '/path',
|
||||
changeManagement: [
|
||||
type: 'SOLMAN'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
)
|
||||
// CTS
|
||||
transportRequestUploadFile script:this,
|
||||
transportRequestId: '001', // typically provided via git commit history
|
||||
filePath: '/path',
|
||||
changeManagement:[
|
||||
type: 'CTS'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
transportRequestUploadFile(
|
||||
script: this,
|
||||
transportRequestId: '001', // typically provided via git commit history
|
||||
filePath: '/path',
|
||||
changeManagement: [
|
||||
type: 'CTS'
|
||||
endpoint: 'https://example.org/cm'
|
||||
]
|
||||
)
|
||||
```
|
||||
|
6
pom.xml
6
pom.xml
@ -1,7 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.jenkins-ci.plugins</groupId>
|
||||
<artifactId>plugin</artifactId>
|
||||
|
@ -37,4 +37,3 @@ class MtaUtils {
|
||||
if (!script.fileExists(targetMtaDescriptor)) throw new AbortException("'${targetMtaDescriptor}' has not been generated.")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -421,16 +421,16 @@ public class ChangeManagement implements Serializable {
|
||||
String clientOpts = '') {
|
||||
String cmCommandLine = '#!/bin/bash'
|
||||
if(clientOpts) {
|
||||
cmCommandLine += """
|
||||
export CMCLIENT_OPTS="${clientOpts}" """
|
||||
cmCommandLine += """
|
||||
export CMCLIENT_OPTS="${clientOpts}" """
|
||||
}
|
||||
cmCommandLine += """
|
||||
cmclient -e '$endpoint' \
|
||||
-u '$username' \
|
||||
-p '$password' \
|
||||
-t ${type} \
|
||||
${command} ${(args as Iterable).join(' ')}
|
||||
"""
|
||||
cmclient -e '$endpoint' \
|
||||
-u '$username' \
|
||||
-p '$password' \
|
||||
-t ${type} \
|
||||
${command} ${(args as Iterable).join(' ')}
|
||||
"""
|
||||
return cmCommandLine
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class StepHelpers {
|
||||
}
|
||||
|
||||
script.echo "[INFO] Retrieving transport request id from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
" Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
" Searching for pattern '${configuration.changeManagement.transportRequestLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
transportRequestId = cm.getTransportRequestId(
|
||||
@ -62,7 +62,7 @@ public class StepHelpers {
|
||||
}
|
||||
|
||||
script.echo "[INFO] Retrieving ChangeDocumentId from commit history [from: ${configuration.changeManagement.git.from}, to: ${configuration.changeManagement.git.to}]." +
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
"Searching for pattern '${configuration.changeManagement.changeDocumentLabel}'. Searching with format '${configuration.changeManagement.git.format}'."
|
||||
|
||||
try {
|
||||
changeDocumentId = cm.getChangeDocumentId(
|
||||
@ -91,15 +91,15 @@ public class StepHelpers {
|
||||
backendType = configuration.changeManagement.type as BackendType
|
||||
} catch(IllegalArgumentException e) {
|
||||
script.error "Invalid backend type: '${configuration.changeManagement.type}'. " +
|
||||
"Valid values: [${BackendType.values().join(', ')}]. " +
|
||||
"Configuration: 'changeManagement/type'."
|
||||
"Valid values: [${BackendType.values().join(', ')}]. " +
|
||||
"Configuration: 'changeManagement/type'."
|
||||
}
|
||||
|
||||
if (backendType == BackendType.NONE) {
|
||||
script.echo "[INFO] Change management integration intentionally switched off. " +
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"other required properties like 'endpoint', 'credentialsId'."
|
||||
"In order to enable it provide 'changeManagement/type with one of " +
|
||||
"[${BackendType.values().minus(BackendType.NONE).join(', ')}] and maintain " +
|
||||
"other required properties like 'endpoint', 'credentialsId'."
|
||||
}
|
||||
|
||||
return backendType
|
||||
|
@ -169,9 +169,9 @@ void call(Map parameters = [:], Closure body = null) {
|
||||
|
||||
try {
|
||||
sh """#!/bin/bash
|
||||
git add .
|
||||
git ${gitConfig} commit -m 'update version ${newVersion}'
|
||||
git tag ${config.tagPrefix}${newVersion}"""
|
||||
git add .
|
||||
git ${gitConfig} commit -m 'update version ${newVersion}'
|
||||
git tag ${config.tagPrefix}${newVersion}"""
|
||||
config.gitCommitId = gitUtils.getGitCommitIdOrNull()
|
||||
} catch (e) {
|
||||
error "[${STEP_NAME}]git commit and tag failed: ${e}"
|
||||
|
@ -177,9 +177,9 @@ void call(parameters = [:]) {
|
||||
"Change document id not provided (parameter: \'changeDocumentId\' or via commit history).")
|
||||
}
|
||||
configuration = configHelper
|
||||
.withMandatoryProperty('transportRequestId',
|
||||
"Transport request id not provided (parameter: \'transportRequestId\' or via commit history).")
|
||||
.use()
|
||||
.withMandatoryProperty('transportRequestId',
|
||||
"Transport request id not provided (parameter: \'transportRequestId\' or via commit history).")
|
||||
.use()
|
||||
|
||||
def uploadingMessage = ['[INFO] Uploading file ' +
|
||||
"'${backendType == BackendType.RFC ? configuration.applicationUrl : configuration.filePath}' " +
|
||||
|
Loading…
x
Reference in New Issue
Block a user