[JIRA] (JENKINS-39066) hudson.util.ArgumentListBuilder quoting incorrectly in procStarter

3 views
Skip to first unread message

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 9:40:01 AM10/18/16
to jenkinsc...@googlegroups.com
Joseph Petersen updated an issue
 
Jenkins / Bug JENKINS-39066
hudson.util.ArgumentListBuilder quoting incorrectly in procStarter
Change By: Joseph Petersen
Summary: hudson.util.ArgumentListBuilder quoting incorrectly {rocStarter in procStarter
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 9:41:01 AM10/18/16
to jenkinsc...@googlegroups.com
Joseph Petersen assigned an issue to Unassigned
Change By: Joseph Petersen
Assignee: Joseph Petersen

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 9:41:02 AM10/18/16
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
Oct 18, 2016, 10:06:05 AM10/18/16
to jenkinsc...@googlegroups.com

dbeck@cloudbees.com (JIRA)

unread,
Oct 18, 2016, 1:27:04 PM10/18/16
to jenkinsc...@googlegroups.com
Daniel Beck commented on Bug JENKINS-39066
 
Re: hudson.util.ArgumentListBuilder quoting incorrectly in procStarter

How about a simple add(…) in the case of an empty parameter?

I looked through the sources, but couldn't find anything that would explain the behavior of (AFAIU) the empty parameter not getting passed.

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 1:56:01 PM10/18/16
to jenkinsc...@googlegroups.com

I took your advice and just did a simple add("") which then suddenly worked on UNIX though not on Windows.

So bottomline:

add("") works on UNIX, but not on Windows.
addQuoted("") works on Windows, but not UNIX.

Added this to confirm
logger.info(cmd.toStringWithQuote());

This comes out of both log run on windows and on unix.
okt. 18, 2016 7:37:43 PM hudson.plugins.accurev.cmd.Login accurevLogin
INFO: login -H accurev:5050 josp ""

Sure the command looks exactly the same. But something is amiss.

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 2:16:01 PM10/18/16
to jenkinsc...@googlegroups.com

This is the current solution which works.

    private static boolean accurevLogin(//
                                        final AccurevServer server, //
                                        final Map<String, String> accurevEnv, //
                                        final FilePath workspace, //
                                        final TaskListener listener, //
                                        final Launcher launcher) throws IOException, InterruptedException {
        listener.getLogger().println("Authenticating with Accurev server...");
        final ArgumentListBuilder cmd = new ArgumentListBuilder();
        cmd.add("login");
        addServer(cmd, server);
        if (server.isUseNonexpiringLogin()) {
            cmd.add("-n");
        }
        cmd.add(server.getUsername());
        if (StringUtils.isEmpty(server.getPassword())) {
            Computer c = Computer.currentComputer();
            if (c == null) {
                Jenkins h = Jenkins.getInstance();
                c = h.getComputer("");
            }
            if (c != null && c.isUnix()) {
                cmd.add("", false);
            } else {
                cmd.addQuoted("", false);
            }
        } else {
            cmd.add(server.getPassword(), true);
        }
        logger.info(cmd.toString());
        logger.info(cmd.toStringWithQuote());
        final boolean success = AccurevLauncher.runCommand("login", launcher, cmd, null, accurevEnv, workspace, listener, logger);
        if (success) {
            listener.getLogger().println("Authentication completed successfully.");
            return true;
        } else {
            return false;
        }
    }

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 2:17:04 PM10/18/16
to jenkinsc...@googlegroups.com
Joseph Petersen edited a comment on Bug JENKINS-39066
This is the current solution which works. It relies on currentComputer but otherwise fallbacks to Jenkins.getComputer. I know that Computer.resolveCLI but it is throwing an expection :(


{code:java}
{code}

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 2:19:01 PM10/18/16
to jenkinsc...@googlegroups.com
Joseph Petersen edited a comment on Bug JENKINS-39066
This is the current solution which works. It relies on currentComputer but otherwise fallbacks to Jenkins.getComputer. I know that Computer.resolveCLI but it is throwing an expection :(
Would be nice if currentComputer would not return null but instead master.

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 3:10:01 PM10/18/16
to jenkinsc...@googlegroups.com
Joseph Petersen edited a comment on Bug JENKINS-39066
Wouldn't that be wonderful if FilePath.isUnix was public? ;)

josephp90@gmail.com (JIRA)

unread,
Oct 18, 2016, 3:10:01 PM10/18/16
to jenkinsc...@googlegroups.com
 
Re: hudson.util.ArgumentListBuilder quoting incorrectly in procStarter

Wouldn't that be wonderful if FilePath.isUnix was public?

dbeck@cloudbees.com (JIRA)

unread,
Oct 18, 2016, 5:01:03 PM10/18/16
to jenkinsc...@googlegroups.com

Well, you could copy its implementation to a utility function, all the fields/getters it acts on are public/have public getters.

https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/FilePath.java#L350...L364

Less than ideal, clearly, but should work.

josephp90@gmail.com (JIRA)

unread,
Oct 19, 2016, 3:52:01 AM10/19/16
to jenkinsc...@googlegroups.com

So mark as resolved or look into why it is behaving differently on Unix and Windows?

dbeck@cloudbees.com (JIRA)

unread,
Oct 19, 2016, 7:49:03 AM10/19/16
to jenkinsc...@googlegroups.com

The latter, if I didn't have an existing giant to-do list

josephp90@gmail.com (JIRA)

unread,
Mar 7, 2020, 1:10:19 AM3/7/20
to jenkinsc...@googlegroups.com
Joseph Petersen assigned an issue to Joseph Petersen
 
Change By: Joseph Petersen
Assignee: Joseph Petersen
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

josephp90@gmail.com (JIRA)

unread,
Mar 7, 2020, 1:15:03 AM3/7/20
to jenkinsc...@googlegroups.com
Joseph Petersen assigned an issue to Unassigned
Reply all
Reply to author
Forward
0 new messages