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

'You can only use one percent sign to separate the cron from the parameters.' displayed while shouldn't. #2

Open
SialSurion opened this issue Feb 23, 2016 · 3 comments

Comments

@SialSurion
Copy link

Hi,

While I wrote a schedule:

0-15 17 * * 3 % environment=RC
0-15 17 * * 4 % environment=QA

There is yellow warning message displayed:

You can only use one percent sign to separate the cron from the parameters.

I think this message should be only displayed if there is more than one percent sign in one line rather than in all box.

Could you please take a look?

Cheers,
Sial

@AlexBaranowski
Copy link

I have same issue with Jenkins ver. 1.655.
Example:
jenkins

I tried to fix it in
src/main/java/org/jenkinsci/plugins/parameterizedschedular/ParameterParser.java
by change checkSanity but then tests failed 😢

  public String checkSanity(String cronTabSpec, ParametersDefinitionProperty parametersDefinitionProperty) {
        for (String s : cronTabSpec.split("\n")){   
            String[] split = s.split(PARAMETER_SEPARATOR);
            if (split.length < 2) {
                continue; 
            }
            if (split.length > 2) {
                return Messages.ParameterizedTimerTrigger_MoreThanOnePercent();
            }
            // split is equal 2 so we have "time % parameters"
            try {
                Map<String, String> parsedParameters = parse(split[1]);
                List<String> parameterDefinitionNames = parametersDefinitionProperty.getParameterDefinitionNames();
                List<String> parsedKeySet = new ArrayList<String>(parsedParameters.keySet());
                parsedKeySet.removeAll(parameterDefinitionNames);
                if (!parsedKeySet.isEmpty()) {
                    return Messages.ParameterizedTimerTrigger_UndefinedParameter(parsedKeySet, parameterDefinitionNames);
                }
            } catch (IllegalArgumentException e) {
                return e.getMessage();
            }
        }
        return null;
    }

Any further help will be welcome 👍

@jwmach1
Copy link
Owner

jwmach1 commented Dec 9, 2016

The little bit of time I had to look at this, it looks like the crontab definition used to be sent into the code above one line at a time. I know that when I was using this (I'm not anymore) it was being used to execute projects with more than one property. I know that's not much help.

@rexroof
Copy link

rexroof commented Jun 12, 2017

It also looks like the checkSanity function would never get to the second check for null parameters. The first if-statement returns in both cases.

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

No branches or pull requests

4 participants