3 | This plug-in provides additional parameter types for jobs, that allow you to cascade
4 | changes and render images or other HTML elements instead of the traditional parameter.
5 |
This is a simple parameter that executes a script and
3 | renders the returned values as an HTML element. This
4 | element can be a list, a dropdown box, radio or check
5 | boxes.
3 | If enabled a text box will appear next to this element and will permit the user to filter its entries.
4 | The list values never get re-evaluated. In other words, the lookup happens in a cached version of the
5 | options.
6 |
3 | By default Dynamic Reference Parameters always include a hidden input for the value.
4 | If your script creates an input HTML element, you can check this option and the
5 | value input field will be omitted.
6 |
3 | Comma separated list of other job parameters referenced in the uno-choice script.
4 | When any of the referenced parameters are updated, the Groovy script will re-evaluate
5 | the choice list using the updated values of referenced parameters.
6 |
Accepts another parameter as reference, and updates itself
3 | whenever the other parameter is changed. The value of the
4 | other parameter is made available as a variable that can
5 | be used in this parameter's script.
This parameter is a special cascade choice parameter. It was
3 | designed based on the cascade choice parameter, so it is also
4 | able to re-render itself whenever another parameter changes.
5 |
6 |
The difference of this parameter is that users have more
7 | freedom on how the HTML element is rendered (if rendered at
8 | all). This is useful in cases where users want to display a
9 | custom HTML element, write JavaScript that renders something
10 | like D3.js or another JavaScript library.
The Script will be evaluated first, and if it fails (e.g. throws an exception),
4 | the Fallback Script will be used as a fallback.
5 |
This script integrates with Script Security plugin
6 | to allow regular Jenkins users to configure this parameter, while limiting what they can do for security.
7 |
8 |
If this script is used for any of the HTML choice types of an Active Choices Reactive Reference Parameter,
9 | the resulting HTML output will be sanitized to remove everything but basic formatting, like script tags, unless the script runs outside the sandbox.
10 | This mode requires approval from a Jenkins administrator to prevent cross-site scripting (HTML) and arbitrary code execution (Groovy).
11 |
--------------------------------------------------------------------------------
/src/main/webapp/css/unochoice.css:
--------------------------------------------------------------------------------
1 | .js-loading-overlay {
2 | position:absolute;
3 | top:0; bottom:0;
4 | left:0; right:0;
5 |
6 | z-index:199;
7 |
8 | background:#fff;
9 | opacity:0.5;
10 |
11 | border-radius: inherit;
12 | }
13 |
14 | .active-choice {
15 | display: flex;
16 | flex-direction: column;
17 | align-items: flex-start;
18 | }
19 |
20 | .uno_choice_filter {
21 | width: 200px;
22 | }
23 |
24 | .ac-spinner {
25 | display: none;
26 | position: absolute;
27 | margin-left: -22px;
28 | margin-top: 10px;
29 | }
30 |
31 | .ac-container__wrapper {
32 | padding-right: 25px
33 | }
34 |
35 | .ac-container {
36 | display: flex;
37 | flex-direction: column;
38 | gap: 5px;
39 | }
40 |
41 | .ac-select {
42 | overflow-y: auto;
43 | border: 0;
44 | width: 100%;
45 | }
46 |
47 | .ac-select:focus-visible {
48 | outline: 0;
49 | }
50 |
51 | .ac-select__input {
52 | padding: 0;
53 | overflow: hidden;
54 | transition: none;
55 | }
56 |
57 | .ac-select__input:has(>select:focus) {
58 | border-color: var(--focus-input-border);
59 | box-shadow: var(--form-input-glow--focus);
60 | outline: none;
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/resources/org/biouno/unochoice/issue63983/TestSandboxAndApproval/users/admin/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Administrator
4 |
5 |
6 | All
7 |
8 |
9 |
10 | All
11 | false
12 | false
13 |
14 |
15 |
16 |
17 | EsFUDz:08c2dac88b514c565c5179d8f29a62fafef3477b138fa79ca7ca7d0031a93650
18 |
19 |
20 | admin@localhost
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014-2020 Ioannis K. Moutsatsos, Bruno P. Kinoshita
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/src/test/resources/org/biouno/unochoice/issue63983/TestSandboxAndApproval/users/summerworkers/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | Summerworkers
4 |
5 |
6 | All
7 |
8 |
9 |
10 | All
11 | false
12 | false
13 |
14 |
15 |
16 |
17 | qmNQcK:20e30ce85a3820d63de52a0e38db6393b7c35a14a8c3b2d286f85b2eee047353
18 |
19 |
20 | summerworkers@localhost
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/main/webapp/help-dynamicReferenceScript.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | This script is evaluated and used to render different HTML elements. The
4 | following elements are present as parameters for the Groovy script.
5 |
28 | When using an image gallery, you must return a list of images. Use the
29 | include pattern to filter the archived artifacts and, if necessary,
30 | execute extra code in your Groovy script to select which files should
31 | be rendered. Below the simplest way to create a gallery with archived
32 | images.
33 |
34 |
35 | return new ArrayList(binding.variables.artifacts.keySet())
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/test/java/org/jenkinsci/plugins/scriptler/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * For testing scriptler-plugin.
27 | */
28 | package org.jenkinsci.plugins.scriptler;
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue69448/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * See JENKINS-69448.
27 | *
28 | * @since 2.6.3
29 | */
30 | package org.biouno.unochoice.issue69448;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue71909/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2024 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * See JENKINS-71909.
27 | *
28 | * @since 2.8.4
29 | */
30 | package org.biouno.unochoice.issue71909;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue72105/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * See JENKINS-72105.
27 | *
28 | * @since 2.8.1
29 | */
30 | package org.biouno.unochoice.issue72105;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue73239/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2025 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * See JENKINS-73239.
27 | *
28 | * @since 2.8.7
29 | */
30 | package org.biouno.unochoice.issue73239;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue74963/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2025 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * See JENKINS-74963.
27 | *
28 | * @since 2.8.7
29 | */
30 | package org.biouno.unochoice.issue74963;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue74967/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2025 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * See JENKINS-74967.
27 | *
28 | * @since 2.8.7
29 | */
30 | package org.biouno.unochoice.issue74967;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue34818/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for global node properties issue. See JENKINS-34818.
27 | *
28 | * @since 1.5.x
29 | */
30 | package org.biouno.unochoice.issue34818;
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue38532/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2016 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for parameters with the equals separator. See JENKINS-38532.
27 | *
28 | * @since 1.5.x
29 | */
30 | package org.biouno.unochoice.issue38532;
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue48448/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for parameters with the equals separator. See JENKINS-48448.
27 | *
28 | * @since 2.1
29 | */
30 | package org.biouno.unochoice.issue48448;
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue49260/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for different folders having same Project name. See JENKINS-49260.
27 | *
28 | * @since 2.2
29 | */
30 | package org.biouno.unochoice.issue49260;
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue62215/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for input element with markup sanitation. See JENKINS-62215
27 | *
28 | * @since 2.4
29 | */
30 | package org.biouno.unochoice.issue62215;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue51296/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 |
26 | /**
27 | * Tests for projectName being correct after renaming project. See JENKINS-51296.
28 | *
29 | * @since 2.2
30 | */
31 | package org.biouno.unochoice.issue51296;
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue63983/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2021 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for Groovy scripts with and without sandbox depending on approval. See JENKINS-63983
27 | *
28 | * @since 2.5.7
29 | */
30 | package org.biouno.unochoice.issue63983;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue61068/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for radio parameter has incorrect default value on parambuild URL. See JENKINS-61068.
27 | *
28 | * @since 2.2.3
29 | */
30 | package org.biouno.unochoice.issue61068;
31 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue65235/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2023 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | /**
26 | * Tests for accessing jenkinsProject context property on multibranch workflows. See JENKINS-65235.
27 | *
28 | * @since 2.6.5
29 | */
30 | package org.biouno.unochoice.issue65235;
31 |
32 |
--------------------------------------------------------------------------------
/src/main/resources/org/biouno/unochoice/CascadeChoiceParameter/cascade-choice-parameter.js:
--------------------------------------------------------------------------------
1 | if (window.makeStaplerProxy) {
2 | window.__old__makeStaplerProxy = window.makeStaplerProxy;
3 | window.makeStaplerProxy = UnoChoice.makeStaplerProxy2;
4 | }
5 |
6 | window.addEventListener("DOMContentLoaded", () => {
7 | document.querySelectorAll(".cascade-choice-parameter-data-holder").forEach((dataHolder) => {
8 | const { name, paramName, randomName, proxyName } = dataHolder.dataset;
9 | const referencedParameters = dataHolder.dataset.referencedParameters;
10 | if (referencedParameters === undefined || referencedParameters === null || referencedParameters.length === 0) {
11 | console.log(`[${name}] - cascade-choice-parameters.js#querySelectorAll#forEach - No parameters referenced!`);
12 | return;
13 | }
14 | const referencedParametersList = dataHolder.dataset.referencedParameters.split(",").map((val) => val.trim());
15 | const filterable = dataHolder.dataset.filterable === "true";
16 | const filterLength = parseInt(dataHolder.dataset.filterLength);
17 |
18 | UnoChoice.renderCascadeChoiceParameter(`#${paramName}`, filterable, name, randomName, filterLength, paramName, referencedParametersList, window[proxyName]);
19 | });
20 |
21 | if (window.makeStaplerProxy && window.__old__makeStaplerProxy) {
22 | window.makeStaplerProxy = window.__old__makeStaplerProxy;
23 | delete window["__old__makeStaplerProxy"];
24 | }
25 | });
26 |
--------------------------------------------------------------------------------
/src/test/resources/org/biouno/unochoice/PipelineWithScriptlerParameters.groovy:
--------------------------------------------------------------------------------
1 | properties([
2 | parameters([
3 | [
4 | $class: 'ChoiceParameter',
5 | choiceType: 'PT_SINGLE_SELECT',
6 | description: 'param001 description',
7 | filterLength: 1,
8 | filterable: true,
9 | name: 'param001',
10 | randomName: 'random-name',
11 | script: [
12 | $class: 'ScriptlerScript',
13 | scriptlerScriptId: 'dummy.groovy',
14 | parameters: [
15 | [name: 'arg1', value: 'bla']
16 | ]
17 | ]
18 | ],
19 | [
20 | $class: 'CascadeChoiceParameter',
21 | choiceType: 'PT_SINGLE_SELECT',
22 | description: 'param002 description',
23 | filterLength: 1,
24 | filterable: true,
25 | name: 'param002',
26 | randomName: 'random-name',
27 | referencedParameters: 'param001',
28 | script: [
29 | $class: 'GroovyScript',
30 | script: [
31 | $class: 'SecureGroovyScript',
32 | script: 'return [PARAM001]',
33 | sandbox: false
34 | ],
35 | fallbackScript: [
36 | $class: 'SecureGroovyScript',
37 | script: 'return []',
38 | sandbox: false
39 | ]
40 | ]
41 | ]
42 | ])
43 | ])
44 |
--------------------------------------------------------------------------------
/src/main/java/org/biouno/unochoice/model/ScriptDescriptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package org.biouno.unochoice.model;
26 |
27 | import hudson.model.Descriptor;
28 |
29 | /**
30 | * Abstract descriptor for scripts.
31 | *
32 | * @author Bruno P. Kinoshita
33 | * @since 0.23
34 | */
35 | public abstract class ScriptDescriptor extends Descriptor
39 | JENKINS-75194
40 | JENKINS-75194
41 |
42 | ENVIRONMENT
43 | PT_SINGLE_SELECT
44 | false
45 | 1
46 |
47 |
48 | ECR_IMAGE_TAG
49 | choice-parameter-aws-ecr-image-tag
50 | 1
51 |
60 | JENKINS-75194
61 | JENKINS-75194
62 |
63 | AWS_REGION
64 | PT_SINGLE_SELECT
65 | false
66 | 1
67 |
68 |
69 |
70 |
71 |
72 |
87 | true
88 |
89 |
90 | false
91 |
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue74967/TestFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2023 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 | package org.biouno.unochoice.issue74967;
25 |
26 | import org.biouno.unochoice.BaseUiTest;
27 | import org.junit.jupiter.api.Test;
28 | import org.jvnet.hudson.test.Issue;
29 | import org.jvnet.hudson.test.recipes.LocalData;
30 | import org.openqa.selenium.By;
31 | import org.openqa.selenium.WebElement;
32 | import org.openqa.selenium.support.ui.ExpectedConditions;
33 | import org.openqa.selenium.support.ui.Select;
34 |
35 | import java.util.List;
36 |
37 | import static org.junit.jupiter.api.Assertions.assertEquals;
38 | import static org.junit.jupiter.api.Assertions.assertTrue;
39 |
40 | /**
41 | * In JENKINS-74967 a JS exception when the user entered anything in the filter field.
42 | * The JavaScript code is not very well-designed (mea-culpa) so it is not easy to test
43 | * it. For that reason, the config.xml attached in this issue was used here to write a
44 | * complete e2e test (i.e. yes, we are killing the ant with an elephant).
45 | */
46 | @Issue("JENKINS-74967")
47 | class TestFilter extends BaseUiTest {
48 |
49 | /**
50 | * Tests that the page loads with paramA=AAA, filter empty, and paramB showing AAA-1, AAA-2, and AAA-3.
51 | * Then, it enters the filter text BB, paramA is updated to BBB (matches filter), which cascades to
52 | * changing paramB to BBB-1, BBB-2, BBB-3.
53 | *
54 | * @throws Exception resolving the test web pages
55 | */
56 | @Test
57 | @LocalData("test")
58 | void test() throws Exception {
59 | driver.get(j.getURL().toString() + "job/test/build");
60 |
61 | wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".jenkins-spinner")));
62 |
63 | WebElement paramA = findSelect("paramA");
64 | assertTrue(paramA.isDisplayed());
65 | assertTrue(paramA.isEnabled());
66 | assertEquals("AAA", new Select(paramA).getFirstSelectedOption().getText());
67 |
68 | List paramB = findRadios("paramB");
69 | for (int i = 0; i < paramB.size(); i++) {
70 | WebElement param = paramB.get(i);
71 | assertTrue(getLabel(param).isDisplayed());
72 | assertTrue(param.isEnabled());
73 | assertEquals("AAA-" + (i + 1), param.getDomAttribute("value"));
74 | }
75 |
76 | WebElement filterElement = driver.findElement(By.cssSelector("div.active-choice[name='parameter'] > input.uno_choice_filter"));
77 | filterElement.sendKeys("BB");
78 |
79 | wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".jenkins-spinner")));
80 |
81 | paramA = findSelect("paramA");
82 | assertTrue(paramA.isDisplayed());
83 | assertTrue(paramA.isEnabled());
84 | assertEquals("BBB", new Select(paramA).getFirstSelectedOption().getText());
85 |
86 | paramB = findRadios("paramB");
87 | for (int i = 0; i < paramB.size(); i++) {
88 | WebElement param = paramB.get(i);
89 | assertTrue(getLabel(param).isDisplayed());
90 | assertTrue(param.isEnabled());
91 | assertEquals("BBB-" + (i + 1), param.getDomAttribute("value"));
92 | }
93 |
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/src/test/js/lib/runner.js:
--------------------------------------------------------------------------------
1 | /*
2 | * PhantomJS Runner QUnit Plugin 1.2.0
3 | *
4 | * PhantomJS binaries: http://phantomjs.org/download.html
5 | * Requires PhantomJS 1.6+ (1.7+ recommended)
6 | *
7 | * Run with:
8 | * phantomjs runner.js [url-of-your-qunit-testsuite]
9 | *
10 | * e.g.
11 | * phantomjs runner.js http://localhost/qunit/test/index.html
12 | */
13 |
14 | /*global phantom:false, require:false, console:false, window:false, QUnit:false */
15 |
16 | (function() {
17 | 'use strict';
18 |
19 | var url, page, timeout,
20 | args = require('system').args;
21 |
22 | // arg[0]: scriptName, args[1...]: arguments
23 | if (args.length < 2 || args.length > 3) {
24 | console.error('Usage:\n phantomjs runner.js [url-of-your-qunit-testsuite] [timeout-in-seconds]');
25 | phantom.exit(1);
26 | }
27 |
28 | url = args[1];
29 | page = require('webpage').create();
30 | if (args[2] !== undefined) {
31 | timeout = parseInt(args[2], 10);
32 | }
33 |
34 | // Route `console.log()` calls from within the Page context to the main Phantom context (i.e. current `this`)
35 | page.onConsoleMessage = function(msg) {
36 | console.log(msg);
37 | };
38 |
39 | page.onInitialized = function() {
40 | page.evaluate(addLogging);
41 | };
42 |
43 | page.onCallback = function(message) {
44 | var result,
45 | failed;
46 |
47 | if (message) {
48 | if (message.name === 'QUnit.done') {
49 | result = message.data;
50 | failed = !result || !result.total || result.failed;
51 |
52 | if (!result.total) {
53 | console.error('No tests were executed. Are you loading tests asynchronously?');
54 | }
55 |
56 | phantom.exit(failed ? 1 : 0);
57 | }
58 | }
59 | };
60 |
61 | page.open(url, function(status) {
62 | if (status !== 'success') {
63 | console.error('Unable to access network: ' + status);
64 | phantom.exit(1);
65 | } else {
66 | // Cannot do this verification with the 'DOMContentLoaded' handler because it
67 | // will be too late to attach it if a page does not have any script tags.
68 | var qunitMissing = page.evaluate(function() { return (typeof QUnit === 'undefined' || !QUnit); });
69 | if (qunitMissing) {
70 | console.error('The `QUnit` object is not present on this page.');
71 | phantom.exit(1);
72 | }
73 |
74 | // Set a timeout on the test running, otherwise tests with async problems will hang forever
75 | if (typeof timeout === 'number') {
76 | setTimeout(function() {
77 | console.error('The specified timeout of ' + timeout + ' seconds has expired. Aborting...');
78 | phantom.exit(1);
79 | }, timeout * 1000);
80 | }
81 |
82 | // Do nothing... the callback mechanism will handle everything!
83 | }
84 | });
85 |
86 | function addLogging() {
87 | window.document.addEventListener('DOMContentLoaded', function() {
88 | var currentTestAssertions = [];
89 |
90 | QUnit.log(function(details) {
91 | var response;
92 |
93 | // Ignore passing assertions
94 | if (details.result) {
95 | return;
96 | }
97 |
98 | response = details.message || '';
99 |
100 | if (typeof details.expected !== 'undefined') {
101 | if (response) {
102 | response += ', ';
103 | }
104 |
105 | response += 'expected: ' + details.expected + ', but was: ' + details.actual;
106 | }
107 |
108 | if (details.source) {
109 | response += "\n" + details.source;
110 | }
111 |
112 | currentTestAssertions.push('Failed assertion: ' + response);
113 | });
114 |
115 | QUnit.testDone(function(result) {
116 | var i,
117 | len,
118 | name = '';
119 |
120 | if (result.module) {
121 | name += result.module + ': ';
122 | }
123 | name += result.name;
124 |
125 | if (result.failed) {
126 | console.log('\n' + 'Test failed: ' + name);
127 |
128 | for (i = 0, len = currentTestAssertions.length; i < len; i++) {
129 | console.log(' ' + currentTestAssertions[i]);
130 | }
131 | }
132 |
133 | currentTestAssertions.length = 0;
134 | });
135 |
136 | QUnit.done(function(result) {
137 | console.log('\n' + 'Took ' + result.runtime + 'ms to run ' + result.total + ' tests. ' + result.passed + ' passed, ' + result.failed + ' failed.');
138 |
139 | if (typeof window.callPhantom === 'function') {
140 | window.callPhantom({
141 | 'name': 'QUnit.done',
142 | 'data': result
143 | });
144 | }
145 | });
146 | }, false);
147 | }
148 | })();
--------------------------------------------------------------------------------
/src/test/java/org/biouno/unochoice/issue51296/TestProjectNameAfterRenaming.java:
--------------------------------------------------------------------------------
1 | /*
2 | * The MIT License (MIT)
3 | *
4 | * Copyright (c) 2014-2020 Ioannis Moutsatsos, Bruno P. Kinoshita
5 | *
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy
7 | * of this software and associated documentation files (the "Software"), to deal
8 | * in the Software without restriction, including without limitation the rights
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | * copies of the Software, and to permit persons to whom the Software is
11 | * furnished to do so, subject to the following conditions:
12 | *
13 | * The above copyright notice and this permission notice shall be included in
14 | * all copies or substantial portions of the Software.
15 | *
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | * THE SOFTWARE.
23 | */
24 |
25 | package org.biouno.unochoice.issue51296;
26 |
27 | import java.io.IOException;
28 | import java.util.Map;
29 |
30 | import hudson.model.Descriptor;
31 |
32 | import static org.junit.jupiter.api.Assertions.assertTrue;
33 | import org.biouno.unochoice.CascadeChoiceParameter;
34 | import org.biouno.unochoice.ChoiceParameter;
35 | import org.biouno.unochoice.model.GroovyScript;
36 | import org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript;
37 | import org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval;
38 | import org.jenkinsci.plugins.scriptsecurity.scripts.languages.GroovyLanguage;
39 | import org.junit.jupiter.api.BeforeEach;
40 | import org.junit.jupiter.api.Test;
41 | import org.jvnet.hudson.test.Issue;
42 | import org.jvnet.hudson.test.JenkinsRule;
43 |
44 | import hudson.model.FreeStyleProject;
45 | import hudson.model.ParametersDefinitionProperty;
46 | import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
47 |
48 | /**
49 | * Tests for projectName being correct after renaming project. See JENKINS-51296.
50 | *
51 | * @since 2.2
52 | */
53 | @Issue("JENKINS-51296")
54 | @WithJenkins
55 | class TestProjectNameAfterRenaming {
56 | private JenkinsRule j;
57 |
58 | // LIST script
59 | private static final String SCRIPT_LIST = "return ['Test', jenkinsProject.getName()]";
60 | private static final String FALLBACK_SCRIPT_LIST = "return ['EMPTY!']";
61 |
62 | private static final String PARAMETER_NAME = "my-parameter-name";
63 |
64 | private static final String PROJECT_NAME_BEFORE = "MyOldJenkinsJob";
65 | private static final String PROJECT_NAME_AFTER = "MyRealJenkinsJob";
66 |
67 | @BeforeEach
68 | void setUp(JenkinsRule j) {
69 | this.j = j;
70 | ScriptApproval.get()
71 | .preapprove(SCRIPT_LIST, GroovyLanguage.get());
72 | ScriptApproval.get()
73 | .preapprove(FALLBACK_SCRIPT_LIST, GroovyLanguage.get());
74 | }
75 |
76 | @Test
77 | void testProjectAreDifferent() throws IOException, Descriptor.FormException {
78 |
79 | FreeStyleProject project = j.createProject(FreeStyleProject.class, PROJECT_NAME_BEFORE);
80 |
81 | GroovyScript listScript = new GroovyScript(new SecureGroovyScript(SCRIPT_LIST, Boolean.FALSE, null),
82 | new SecureGroovyScript(FALLBACK_SCRIPT_LIST, Boolean.FALSE, null));
83 |
84 | ChoiceParameter listParam = new ChoiceParameter(PARAMETER_NAME, "description...", "random-name", listScript,
85 | CascadeChoiceParameter.PARAMETER_TYPE_SINGLE_SELECT, false, 1);
86 |
87 | ParametersDefinitionProperty paramsDef = new ParametersDefinitionProperty(listParam);
88 |
89 | project.addProperty(paramsDef);
90 |
91 | Map