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

Helper miss method make job go fail #66

Closed
Cheava opened this issue Apr 9, 2020 · 7 comments
Closed

Helper miss method make job go fail #66

Cheava opened this issue Apr 9, 2020 · 7 comments
Assignees
Labels
question Further information is requested

Comments

@Cheava
Copy link

Cheava commented Apr 9, 2020

When I want to use Module's OUT to add param in CFG, like below,

        steps {
          MPLPipelineConfigMerge(MPLModule())
        }

jenkins's job go failure, the error message is attached below

groovy.lang.MissingMethodException: No signature of method: static com.griddynamics.devops.mpl.Helper.configEntrySet() is applicable for argument types: (java.util.LinkedHashMap) values: [[...]]]

I have view the source code, this error is caused by this line.
https://github.com/griddynamics/mpl/blame/master/src/com/griddynamics/devops/mpl/MPLConfig.groovy#L89
The missing method was remove on this #46 .
Because the method is missing, I have to uncomment the " Helper.configEntrySet(this.@config) ".
Finally, the job run well . But CFG seems no change after merging with OUT.
Can you have a look on this code?
And could you tell why CFG seems no change after merging with OUT?

@sparshev
Copy link
Collaborator

Hi @Cheava ,

Yeah, you can't merge the entire OUT to the existing pipeline config. Sorry for such mistake - it was not added to the documentation. The method MPLPipelineConfigMerge was designed to be used as:

MPLPipelineConfigMerge(MPLModule().key)

Means you have to put data to specific OUT.key value and after that use such key to access the data and merge it.

The MPLConfig object denies to use config object for iteration - you have to know the first key you need. After that first key will return you dict/array/value or null - which you will be able to use further in your logic. Otherwise the logic in your pipeline will miss the important information - what exactly you doing there.

Also I think I will add some documentation about that and some checks to tell what's exactly wrong.

@sparshev
Copy link
Collaborator

About the second part - when the CFG is not changed after merging - could you please describe steps to reproduce? It's quite hard to understand which CFG should be changed.

@sparshev
Copy link
Collaborator

Removing of the Helper.configEntrySet method looks wrong, but overall - you will face the same result, beacuse you trying to iterate over MPLConfig object - and such action was intentionally denied.

@sparshev sparshev self-assigned this Apr 10, 2020
@sparshev sparshev added the question Further information is requested label Apr 10, 2020
@Cheava
Copy link
Author

Cheava commented Apr 11, 2020

Thank you for the answer. I will try the usage you mentioned later.
The second question is based on my view of MPLPipelineConfigMerge, I think MPLPipelineConfigMerge is aim to merge OUT and CFG, to update/add some CFG propertity, from OUT. I don't know if I misunderstand the usage.

The code I write like below

### Build.groovy
......
//deliver cutomer  value
OUT.'project.type' = 'Docker'


### Deploy.groovy
......
//check if the key is exist
if(CFG.'project.type' == 'Docker'){
......
}

### NestedPipeline.groovy
.....
   stage( 'Build' ) {
        when { expression { MPLModuleEnabled() } }
        steps {
          MPLPipelineConfigMerge(MPLModule())
        }
      }
   stage( 'Deploy' ) {
        when { expression { MPLModuleEnabled() } }
        steps {
          MPLPipelineConfigMerge(MPLModule())
        }
      }
.....

@Cheava
Copy link
Author

Cheava commented Apr 11, 2020

I just try the code 'MPLPipelineConfigMerge(MPLModule().key)' as below:

### Build.groovy
......
//deliver cutomer  value
OUT.'project.type' = 'Docker'
OUT.'project.home' = '/usr/local'


### Deploy.groovy
......
echo "${CFG.project}"
......
}

### NestedPipeline.groovy
.....
   stage( 'Build' ) {
        when { expression { MPLModuleEnabled() } }
        steps {
          MPLPipelineConfigMerge(MPLModule().project)
        }
      }
   stage( 'Deploy' ) {
        when { expression { MPLModuleEnabled() } }
        steps {
          MPLPipelineConfigMerge(MPLModule().project)
        }
      }
.....

According to the echo log, CFG.project is 'null' .

@sparshev
Copy link
Collaborator

Hi @Cheava

Right, it will be null, because only the value of OUT.project is merged. Means in the CFG you will see CFG.type and CFG.home. Hopefully you got the idea: if you want to see CFG.project in Deploy - you need to put project into OUT.build for example and use it to merge.

@Cheava
Copy link
Author

Cheava commented Apr 12, 2020

Yeah, I have tried the way you said, It works.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants