adobe / aio-cli-plugin-cloudmanager

Cloud Manager plugin for the Adobe I/O CLI
Apache License 2.0
46 stars 33 forks source link

pipeline:create-execution: Write execution id to stdout #224

Open kwin opened 3 years ago

kwin commented 3 years ago

It is useful to have the id of the newly created execution id available in the stdout (for non-interactive use cases). This is not the case for https://github.com/adobe/aio-cli-plugin-cloudmanager/blob/b95ae82604c89f2bf8512c36cb7d5ca023dc1864/src/commands/cloudmanager/pipeline/create-execution.js#L35 as the spinner is overwriting output in stdout.

The only way to get hold of the output is via the {{-a}} option: https://github.com/wblachowski/cm-jenkins-helpers/blob/7762702130cec073abddef51eb4268a8d28465bd/jenkins-config/pipelines/pipeline-cm-deploy.Jenkinsfile#L14

The return value of of the run method is not evaluated. A table should be emitted similar to what is done in https://github.com/adobe/aio-cli-plugin-cloudmanager/blob/b95ae82604c89f2bf8512c36cb7d5ca023dc1864/src/commands/cloudmanager/execution/get-step-details.js#L42. That way both json and regular format could be supported.

justinedelson commented 3 years ago

I don't know that the table is the right output in this case, but this seems to be a macro case of a broader issue where the commands should all support a non-interactive mode. The effect of that will vary, but certainly the spinners in general should not be output in a non-interactive mode.

I don't really understand that use case though -- why isn't the Jenkins plugin being used?

kwin commented 3 years ago

why isn't the Jenkins plugin being used?

Are you referring to https://plugins.jenkins.io/adobe-cloud-manager/? This does not support Jenkins Pipelines and only the request to trigger a new execution (without waiting for it).

I also considered using https://github.com/adobe/aio-lib-java-cloudmanager in a shared library, but this just doesn't seem mature enough yet and also Jenkins is advocating against executing too much with Groovy (https://www.jenkins.io/doc/book/pipeline/pipeline-best-practices/#making-sure-to-use-groovy-code-in-pipelines-as-glue). Therefore I decided to go with calling aio-cli-plugin-cloudmanager from Jenkins.

justinedelson commented 3 years ago

Are you referring to https://plugins.jenkins.io/adobe-cloud-manager/? This does not support Jenkins Pipelines and only the request to trigger a new execution (without waiting for it).

Yes, this seems like a better solution IMO if the use case is specifically to Jenkins. I don't know what is necessary to support Jenkins Pipelines in that plugin but I assume that would be the proper place for it.

kwin commented 3 years ago

https://plugins.jenkins.io/adobe-cloud-manager/ is not based on https://github.com/adobe/aio-lib-java-cloudmanager and also has no issue tracker, therefore it is close to impossible to collaborate. Also this does not rely on any Adobe libraries but just the swagger definition to build its own client. Therefore I came to the conclusion to disregard this approach/plugin.

justinedelson commented 3 years ago

It actually looks like it was moved over in December: https://github.com/jenkinsci/adobe-cloud-manager-plugin/pull/1

Agree that no issues is an interesting project choice... I created https://github.com/jenkinsci/adobe-cloud-manager-plugin/pull/2 (using PRs as a issues workaround)

kwin commented 3 years ago

I created 5 issues: https://issues.jenkins.io/browse/JENKINS-64929?jql=project%20%3D%20JENKINS%20AND%20component%20%3D%20adobe-cloud-manager-plugin.

kwin commented 3 years ago

One further question before I come up with PRs for the Jenkins Plugin: Is that now maintained by Adobe or by Perficient? Who is responsible for pushing out releases in the future. Given that the last release is 1 year old gives me the impression that the plugin is pretty dead.

justinedelson commented 3 years ago

As I understand it, it is a community project with participants from both Perficient and Adobe. I do not know the full backstory, but I assume it is where it is because that is what works best for Jenkins plugins.

kwin commented 3 years ago

It doesn't seem that there is much going forward with the Jenkins plugin. Would you consider including a patch which just fixes the issue for create-execution for now (i.e. set a proper exit code and don't use animations for non-interactive usage via a dedicated flag)?

kwin commented 3 years ago

I found a workaround: The actionType simple is used by cli-ux automatically in case the environment variable CI is set (https://github.com/oclif/cli-ux/blob/6dfa79da103cc608dc1b7b4790eb1a084c435c5b/src/config.ts#L20). In addition you have to be aware of the fact the the action gives out by default to stderr instead of stdout (https://github.com/oclif/cli-ux/blob/6dfa79da103cc608dc1b7b4790eb1a084c435c5b/src/action/base.ts#L30) so you have to make sure to capture stderr.

justinedelson commented 3 years ago

@kwin my preference would be to have a generic --non-interactive flag and have that work consistently across commands. But starting with one or two commands would be fine with me.