Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-41765

groovy CLI command cannot be used with stdin via SSH

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Component/s: cli, core
    • Labels:
      None
    • Similar Issues:

      Description

      There's no reason this shouldn't be possible. Let's allow groovy command use via SSH CLI.

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Daniel Beck
            Path:
            core/src/main/java/hudson/cli/GroovyCommand.java
            http://jenkins-ci.org/commit/jenkins/0d3d6b65bf134ba01d67908db63212dc54aa1c58
            Log:
            [FIX JENKINS-41765] Allow groovy CLI command via SSH

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Daniel Beck Path: core/src/main/java/hudson/cli/GroovyCommand.java http://jenkins-ci.org/commit/jenkins/0d3d6b65bf134ba01d67908db63212dc54aa1c58 Log: [FIX JENKINS-41765] Allow groovy CLI command via SSH
            Hide
            danielbeck Daniel Beck added a comment -

            Fixed in 2.46

            Show
            danielbeck Daniel Beck added a comment - Fixed in 2.46
            Hide
            ddaumiller Dorian Daumiller added a comment - - edited

            This doesn't seem to work.

            When trying to execute a groovy command over the ssh method, Jenkins complains about me wanting to use the -remoting mode:

            java -jar ./jenkins-cli.jar -ssh -user **** -i **** -s http://myserver:1234/jenkins/testing/ groovy command.groovy 
            ERROR: This command is requesting the deprecated -remoting mode. See https://jenkins.io/redirect/cli-command-requires-channel

            The URL btw points to the not yet quite complete CLI documentation (which mentions that some commands wouldn't work, but not which ones...)

            The command was a simple println

            Show
            ddaumiller Dorian Daumiller added a comment - - edited This doesn't seem to work. When trying to execute a groovy command over the ssh method, Jenkins complains about me wanting to use the -remoting mode: java -jar ./jenkins-cli.jar -ssh -user **** -i **** -s http: //myserver:1234/jenkins/testing/ groovy command.groovy ERROR: This command is requesting the deprecated -remoting mode. See https: //jenkins.io/redirect/cli-command-requires-channel The URL btw points to the not yet quite complete CLI documentation (which mentions that some commands wouldn't work, but not which ones...) The command was a simple println
            Hide
            ddaumiller Dorian Daumiller added a comment -

            Same when I try groovy from standard-in
            java -jar ./jenkins-cli.jar -ssh -user **** -i **** -s http://myserver:1234/jenkins/testing/ groovy println 'hello world'ERROR: This command is requesting the deprecated -remoting mode. See https://jenkins.io/redirect/cli-command-requires-channel

            Show
            ddaumiller Dorian Daumiller added a comment - Same when I try groovy from standard-in java -jar ./jenkins-cli.jar -ssh -user **** -i **** -s http://myserver:1234/jenkins/testing/ groovy println 'hello world'ERROR: This command is requesting the deprecated -remoting mode. See https://jenkins.io/redirect/cli-command-requires-channel
            Hide
            danielbeck Daniel Beck added a comment -

            When trying to execute a groovy command over the ssh method, Jenkins complains about me wanting to use the -remoting mode

            Only the remoting mode can access local files.

            which mentions that some commands wouldn't work, but not which ones

            Basically a direct consequence of extensibility, there can never be a complete list.

            Same when I try groovy from standard-in

            That's not stdin. stdin is when you use a pipe or input redirection. What you're doing isn't supported by the documentation at all (you're telling it to read from a file called "println"):

            java -jar jenkins-cli.jar -s … groovy [SCRIPT] [ARGUMENTS ...]
            SCRIPT : Script to be executed. File, URL or '=' to represent stdin.

             

            Show
            danielbeck Daniel Beck added a comment - When trying to execute a groovy command over the ssh method, Jenkins complains about me wanting to use the -remoting mode Only the remoting mode can access local files. which mentions that some commands wouldn't work, but not which ones Basically a direct consequence of extensibility, there can never be a complete list. Same when I try groovy from standard-in That's not stdin. stdin is when you use a pipe or input redirection. What you're doing isn't supported by the documentation at all (you're telling it to read from a file called "println"): java -jar jenkins-cli.jar -s … groovy [SCRIPT] [ARGUMENTS ...] SCRIPT : Script to be executed. File, URL or '=' to represent stdin.  
            Hide
            ddaumiller Dorian Daumiller added a comment -

            Understood.

            writing the command into a command.groovy and then piping it into the groovy CLI command worked

            This pipeline

            writeFile file: 'cmd.groovy', text: getCommandText()
            def getCommandText() {
            '''
            println 'HelloWorld'
            '''
            }
            sh 'cat cmd.groovy | java -jar ./jenkins-cli.jar -ssh -user * -i * -s http://serv:14/ groovy ='
            

            looks like this

            Running shell script
            + cat cmd.groovy | java -jar ./jenkins-cli.jar -ssh -user **** -i **** -s http://serv:14/ groovy =
            HelloWorld
            

            Thanks for clarifying

            Show
            ddaumiller Dorian Daumiller added a comment - Understood. writing the command into a command.groovy and then piping it into the groovy CLI command worked This pipeline writeFile file: 'cmd.groovy' , text: getCommandText() def getCommandText() { ''' println 'HelloWorld' ''' } sh 'cat cmd.groovy | java -jar ./jenkins-cli.jar -ssh -user * -i * -s http: //serv:14/ groovy =' looks like this Running shell script + cat cmd.groovy | java -jar ./jenkins-cli.jar -ssh -user **** -i **** -s http: //serv:14/ groovy = HelloWorld Thanks for clarifying

              People

              • Assignee:
                danielbeck Daniel Beck
                Reporter:
                danielbeck Daniel Beck
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: