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

Parameterized Generators and Pipelines #2132

Merged
merged 166 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
e11260a
Parameterised build pipeline generator
M-Davies Oct 8, 2020
7fb794e
Implement file path param in pipelines
M-Davies Oct 14, 2020
810d5b3
Pass in new params to pr tester
M-Davies Oct 15, 2020
417e273
configureBuild is already declared, add test stub
M-Davies Oct 15, 2020
5cad197
Merge branch 'master' into parameterised_everything
M-Davies Oct 28, 2020
0cb37e1
Better error handling for regen
M-Davies Oct 30, 2020
3aff2b6
Remove inline if's
M-Davies Oct 30, 2020
b58a2f5
Use elvis operators
M-Davies Nov 6, 2020
b3dce3e
Multiple Regen updates
M-Davies Nov 6, 2020
d17a132
Clean up whitespaces
M-Davies Nov 12, 2020
f0c6c18
Create initial defaults json
M-Davies Nov 27, 2020
db96a8a
Merge branch 'master' into parameterised_everything
M-Davies Nov 27, 2020
076180b
Don't generate triggers if no schedule
M-Davies Nov 30, 2020
58e2ce5
Parameterise as much as possible in defaults.json
M-Davies Nov 30, 2020
8a3589f
Try using jenkins readJson
M-Davies Dec 1, 2020
9e16f75
Try as empty stub
M-Davies Dec 3, 2020
67e9115
Try with empty func
M-Davies Dec 3, 2020
898e306
Try as list
M-Davies Dec 3, 2020
ce81162
Try replicating jenkins src impl
M-Davies Dec 3, 2020
e54532b
Basic def function declaration
M-Davies Dec 3, 2020
35a8ce7
Try as string method (since java.langString is classname in error)
M-Davies Dec 3, 2020
1d4d100
Ensure to specifiy map when pulling in JSON
M-Davies Dec 3, 2020
73b6bea
Try declaring as a func
M-Davies Dec 4, 2020
0c54207
Change implementation back to file since readJSON cannot be done with…
M-Davies Dec 4, 2020
0a1207c
Specify param name in impl
M-Davies Dec 4, 2020
5ce8be3
It's parseText for strings *facepalm*
M-Davies Dec 4, 2020
5988a7c
Use readFile outside of json slurp
M-Davies Dec 4, 2020
0b37810
Use defs, specify param name
M-Davies Dec 4, 2020
5628930
Move all read files into master node
M-Davies Dec 4, 2020
faf7f04
Merge branch 'master' into parameterised_everything
M-Davies Dec 4, 2020
3b48b63
Ensure the build testers have access to platform configs
M-Davies Dec 4, 2020
780529a
Revert addition of timestamps
M-Davies Dec 4, 2020
8d400ff
Download the defaults.json file instead of trying to open it
M-Davies Dec 4, 2020
f2aefaf
Try parse
M-Davies Dec 4, 2020
7a4e4fc
Create URL class instance seperatly
M-Davies Dec 4, 2020
c368349
Remove unessassary json convert
M-Davies Dec 4, 2020
d9901b1
Update param to current version
M-Davies Dec 4, 2020
652c8a6
Remove unessassry workspace paths
M-Davies Dec 4, 2020
ab4ec74
see if adding scm checkout back in fixes not found lib
M-Davies Dec 4, 2020
54c4e15
Fix bug in version pipeline, now will always use sanitised value
M-Davies Dec 4, 2020
2cd20d7
Init default config paths after java version update parsing
M-Davies Dec 4, 2020
c70229d
Spelling
M-Davies Dec 4, 2020
036a66c
Remove as Map
M-Davies Dec 5, 2020
5699b0b
Instantiate as a map
M-Davies Dec 5, 2020
85b31df
Try not parsing at all?
M-Davies Dec 5, 2020
2b50721
Pretty print JSON to prevent parising error
M-Davies Dec 5, 2020
488c2c2
Remove extra parsing in downstream pipeline
M-Davies Dec 5, 2020
8203dc6
Add error handling for missing JSON file
M-Davies Dec 5, 2020
0a7dc7e
defaultJson -> defaultsJson
M-Davies Dec 5, 2020
59a10b9
Pass in json defaults to pr tester
M-Davies Dec 5, 2020
f3989ee
Fix bug in triggerSchedule setting
M-Davies Dec 6, 2020
6177dd0
Pretty print out config for top level generator
M-Davies Dec 6, 2020
830aa30
Add missing params to config regen script
M-Davies Dec 6, 2020
ff7dce5
Update other regen files to match working jdk8
M-Davies Dec 7, 2020
b436e12
Update main pipeline files to match jdk8
M-Davies Dec 7, 2020
c0c4f6d
Remove unimportant pipelineSchedule
M-Davies Dec 7, 2020
055130a
Move checkout further up
M-Davies Dec 10, 2020
ec7a84e
Parameterise the defaults json
M-Davies Dec 10, 2020
5235353
Move defaults json further up
M-Davies Dec 10, 2020
85e1516
Trial loading lib after checkout in downstream regen
M-Davies Dec 10, 2020
2b75374
Pretty print out in regen
M-Davies Dec 10, 2020
c80e3b3
Parameterise lib path, strong defaultsJson description
M-Davies Dec 11, 2020
782fb4b
Parameterise regen script path
M-Davies Dec 11, 2020
634e1da
Parameterise lib and downstream basefile paths, intelligently pulling…
M-Davies Dec 14, 2020
e82a4ec
More credential changes
M-Davies Dec 15, 2020
d59a2cd
Renamed var and switch back user/pass
M-Davies Dec 15, 2020
ba368bd
Try with username/colon
M-Davies Dec 15, 2020
9ba9b37
More credential changes
M-Davies Dec 15, 2020
257e104
double quotes
M-Davies Dec 17, 2020
432df51
single quotes
M-Davies Dec 17, 2020
bb87771
access var directly
M-Davies Dec 17, 2020
ec26e9e
double quotes var
M-Davies Dec 17, 2020
08baf2d
single quotes var (normal)
M-Davies Dec 17, 2020
572daaa
Merge branch 'parameterised_everything' of github.com:M-Davies/openjd…
M-Davies Dec 18, 2020
96ce540
Strongify defaults param
M-Davies Dec 18, 2020
f450e97
Merge branch 'master' into parameterised_everything
M-Davies Dec 18, 2020
faa05d2
Renames jobTemplateDirectories to templateDirectories
M-Davies Dec 21, 2020
d253c5e
Trial checkout system in build generator
M-Davies Dec 22, 2020
43af112
Manually create methods for pipeline generator since there's no lib t…
M-Davies Dec 23, 2020
21ac069
Minor updates
M-Davies Dec 23, 2020
56f9d70
Remove WORKSPACE from params
M-Davies Dec 23, 2020
1ef7cc1
Ensure we use the right template path and checkout
M-Davies Dec 23, 2020
e0269ce
Always clean up
M-Davies Dec 23, 2020
5ec0a3f
Clean up boolean logic
M-Davies Dec 23, 2020
b37fb22
Try parsing the boolean
M-Davies Dec 23, 2020
5c697da
Try using a if else block
M-Davies Dec 23, 2020
9f56a10
Try using a noSchedule config
M-Davies Dec 23, 2020
cd26749
Remove potentinally useless try-catch
M-Davies Dec 23, 2020
fdf383b
Remove attempts at changing the template logic
M-Davies Jan 5, 2021
34fee6c
Add Repo Switching to Downstream job generator
M-Davies Jan 6, 2021
06c799f
Remove RepoHandler from top level files
M-Davies Jan 6, 2021
f6861da
Declare closure outside of scope
M-Davies Jan 6, 2021
7912b57
Finish setting up generators, passing down everything the jobs
M-Davies Jan 6, 2021
a4c3c6a
Replace empty pipelineSchedule in config
M-Davies Jan 6, 2021
15c5478
Conform remaining files
M-Davies Jan 7, 2021
7517ea1
Try update version after normal to be consistent
M-Davies Jan 8, 2021
046df46
Make generators less inclusive
M-Davies Jan 8, 2021
4ac8d3f
Declare var outside of try catch
M-Davies Jan 8, 2021
d05f5e9
f
M-Davies Jan 8, 2021
c7df168
Enter blank checkout creds if they don't exist
M-Davies Jan 8, 2021
b26ec94
Merge branch 'parameterised_everything' of github.com:M-Davies/openjd…
M-Davies Jan 10, 2021
77458bd
MAke lib load in pipeline a global exception
M-Davies Jan 10, 2021
25b3d57
Mapify user remote configs
M-Davies Jan 12, 2021
3607292
Do map parsing further up
M-Davies Jan 12, 2021
08ef896
Try constructor map
M-Davies Jan 12, 2021
e3c2bc8
Try declaring "as Map"
M-Davies Jan 12, 2021
455e9a6
Try using json slurper to parse map to be consistent
M-Davies Jan 12, 2021
8a20767
Use JsonSluprers across downstream generation
M-Davies Jan 12, 2021
e2c06b6
Try using dot logic for assigning json values
M-Davies Jan 12, 2021
e39801e
Add use adopt bash scripts param
M-Davies Jan 12, 2021
99c9b42
Introduce constructor for build_base_file
M-Davies Jan 12, 2021
d0ec0f9
Remove hashmap references in class instantiation
M-Davies Jan 18, 2021
9c2897a
Remove hashmap values
M-Davies Jan 18, 2021
0766044
Clean up Platform config parsing
M-Davies Jan 18, 2021
8e5e151
Ensure file is created and ran
M-Davies Jan 18, 2021
74c44f9
Try creating files first
M-Davies Jan 18, 2021
b3f73ed
Try specify true
M-Davies Jan 18, 2021
53303cc
try checking if it is a true string
M-Davies Jan 18, 2021
d164f93
stringify everything
M-Davies Jan 18, 2021
53de198
Booleanify useAdoptBashScripts
M-Davies Jan 18, 2021
5dcd51e
try normal logic
M-Davies Jan 18, 2021
4eebfab
See what useAdoptBashScripts is
M-Davies Jan 18, 2021
804e08e
debug
M-Davies Jan 18, 2021
bb929db
Move debug
M-Davies Jan 18, 2021
6ef6ae0
Rejig order of params
M-Davies Jan 18, 2021
94e5b5c
debug
M-Davies Jan 19, 2021
1c2678e
Try using file redirect
M-Davies Jan 19, 2021
d5793a8
Adjust how branch and URL is determinted for platform config pulling
M-Davies Jan 20, 2021
58defe4
debug
M-Davies Jan 20, 2021
dc8677c
Addiotional https
M-Davies Jan 20, 2021
4803b27
rm debug
M-Davies Jan 20, 2021
96989c6
Remove extra uneeded parsing code
M-Davies Jan 20, 2021
84f0623
Allow generation of useAdoptBashScripts
M-Davies Jan 20, 2021
f70268b
Merge branch 'master' into parameterised_everything
M-Davies Jan 21, 2021
7d8657f
Add weekly template
M-Davies Jan 21, 2021
8db00b6
Amend failing tests
M-Davies Jan 21, 2021
09fba71
Update testers
M-Davies Jan 21, 2021
3d79cb3
Try again with tests
M-Davies Jan 21, 2021
da5fc5e
Cast and set splitAdoptUrl as object
M-Davies Jan 21, 2021
4539123
triggerSchedule -> pipelineSchedule
M-Davies Jan 22, 2021
70aa376
Update tester
M-Davies Jan 22, 2021
430d519
Change around scripts to add common stuff into bash
M-Davies Jan 22, 2021
4d24f2a
Flesh out testing suite for RepoHandler
M-Davies Jan 22, 2021
b7be38d
Remove duped JDK14 Aix key
M-Davies Jan 23, 2021
c57a6db
First doc updates
M-Davies Jan 26, 2021
a479d01
Merge branch 'master' into parameterised_everything
M-Davies Jan 26, 2021
6bdee28
More brevity on build generator output
M-Davies Jan 26, 2021
247885e
Comment and compatibility upgrades
M-Davies Jan 26, 2021
4a2c14f
Add in an additional check for platforms on a failed direct link
M-Davies Jan 26, 2021
1276acf
Debug out better
M-Davies Jan 26, 2021
a507f27
Amend config location for test builds
M-Davies Jan 26, 2021
a1d14c2
Merge branch 'master' into parameterised_everything
M-Davies Jan 26, 2021
04a737a
Specify no OS on linux pr build
M-Davies Jan 26, 2021
6e2fbc0
Reduce duration of build generator by querying adopt api
M-Davies Jan 26, 2021
10a6163
Functionise download script
M-Davies Jan 28, 2021
20fe05b
Clean up echos, make bash method a function
M-Davies Jan 28, 2021
7658666
Use regex when checking error code
M-Davies Jan 28, 2021
2c2f671
Remove TODO's and update other pipeline files
M-Davies Jan 29, 2021
6211859
Minor comment and styling updates
M-Davies Jan 30, 2021
87b5bdd
Align map entries, replace semi-colon with colon
M-Davies Feb 1, 2021
2025424
Remove compile testing on pr tester
M-Davies Feb 1, 2021
1de8a8b
Change name of jenkins credentials
M-Davies Feb 2, 2021
17bbc5b
Merge branch 'master' into parameterised_everything
M-Davies Feb 2, 2021
0079363
USE_ADOPT_BASH_SCRIPTS -> USE_ADOPT_SHELL_SCRIPTS
M-Davies Feb 3, 2021
8d762f9
Made nessassary changes
M-Davies Feb 3, 2021
337a252
Merge branch 'master' into parameterised_everything
M-Davies Feb 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
VARIANT: ${{ matrix.vm }}
TARGET_OS: ${{ matrix.os }}
FILENAME: OpenJDK.tar.gz
# Don't set the OS as we use both linux and alpine-linux
PLATFORM_CONFIG_LOCATION: AdoptOpenJDK/openjdk-build/master/build-farm/platform-specific-configurations


- uses: actions/upload-artifact@v2

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ workspace
pipelines/.gradle
pipelines/gradle-cache
pipelines/target
**/.DS_Store
5 changes: 4 additions & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ In order to test whether your changes work use the [test-build-script-pull-reque
Pass it your fork name (e.g. https://github.com/sxa555/openjdk-build) and the name of the branch and it will run a build using your updated scripts.
For more information, see the [PR testing documentation](./pipelines/build/prTester/README.md).

## I want to use my own configuration files or scripts on my own Jenkins instance. How do I do it?

Check out [Adopt's guide]((docs/UsingOurScripts.md)) to setting up your own scripts and configurations (while not having to keep up with Adopt's changes)!

## Which OS levels do we build on?

The operating systems/distributions which we build or are documented in the
Expand All @@ -131,4 +135,3 @@ Runtime platforms are in our [supported platforms page](https://adoptopenjdk.net

The following PR: https://github.com/AdoptOpenJDK/openjdk-build/pull/2416
demonstrates changes required to add a new build pipeline param, and also associated version/platform job configurations for setting the value when needed.

4 changes: 2 additions & 2 deletions build-farm/make-adopt-build-farm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ then
# Use Adopt API to get the JDK Head number
echo "This appears to be JDK Head. Querying the Adopt API to get the JDK HEAD Number (https://api.adoptopenjdk.net/v3/info/available_releases)..."
JAVA_FEATURE_VERSION=$(curl -q https://api.adoptopenjdk.net/v3/info/available_releases | awk '/tip_version/{print$2}')

# Checks the api request was successful and the return value is a number
if [ -z "${JAVA_FEATURE_VERSION}" ] || ! [[ "${JAVA_FEATURE_VERSION}" -gt 0 ]]
then
echo "RETRYWARNING: Query ${retryCount} failed. Retrying in 30 seconds (max retries = ${retryMax})..."
retryCount=$((retryCount+1))
retryCount=$((retryCount+1))
sleep 30s
else
echo "JAVA_FEATURE_VERSION FOUND: ${JAVA_FEATURE_VERSION}" && break
Expand Down
59 changes: 57 additions & 2 deletions build-farm/set-platform-specific-configurations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,60 @@ fi

export VARIANT_ARG="--build-variant ${VARIANT}"

# shellcheck disable=SC1091,SC1090
source "$SCRIPT_DIR/platform-specific-configurations/${OPERATING_SYSTEM}.sh"
# Create placeholders for curl --output
M-Davies marked this conversation as resolved.
Show resolved Hide resolved
if [ ! -d "$SCRIPT_DIR/platform-specific-configurations" ]
then
mkdir "$SCRIPT_DIR/platform-specific-configurations"
fi
if [ ! -f "$SCRIPT_DIR/platform-specific-configurations/platformConfigFile.sh" ]
then
touch "$SCRIPT_DIR/platform-specific-configurations/platformConfigFile.sh"
fi
PLATFORM_CONFIG_FILEPATH="$SCRIPT_DIR/platform-specific-configurations/platformConfigFile.sh"

# Setup for platform config download
rawGithubSource="https://raw.githubusercontent.com"
ret=0
fileContents=""

# Uses curl to download the platform config file
# param 1: LOCATION - Repo path to where the file is located
# param 2: SUFFIX - Operating system to append
function downloadPlatformConfigFile () {
echo "Attempting to download platform configuration file from ${rawGithubSource}/$1/$2"
# make-adopt-build-farm.sh has 'set -e'. We need to disable that for the fallback mechanism, as downloading might fail
set +e
curl "${rawGithubSource}/$1/$2" > "${PLATFORM_CONFIG_FILEPATH}"
ret=$?
# A download will succeed if location is a directory, so we also check the contents are valid
fileContents=$(cat $PLATFORM_CONFIG_FILEPATH)
set -e
}

# Attempt to download and source the user's custom platform config
downloadPlatformConfigFile "${PLATFORM_CONFIG_LOCATION}" ""
# Regex to spot github api error messages similar to "404: Not Found"
contentsErrorRegex="#!/bin/bash"

if [ $ret -ne 0 ] || [[ ! $fileContents =~ $contentsErrorRegex ]]
then
# Check to make sure that a OS file doesn't exist if we can't find a config file from the direct link
echo "[WARNING] Failed to find a user configuration file, ${rawGithubSource}/${PLATFORM_CONFIG_LOCATION} is likely a directory so we will try and search for a ${OPERATING_SYSTEM}.sh file."
karianna marked this conversation as resolved.
Show resolved Hide resolved
downloadPlatformConfigFile "${PLATFORM_CONFIG_LOCATION}" "${OPERATING_SYSTEM}.sh"

if [ $ret -ne 0 ] || [[ ! $fileContents =~ $contentsErrorRegex ]]
then
# If there is no user platform config, use adopt's as a default instead
echo "[WARNING] Failed to download a user platform configuration file. Downloading Adopt's ${OPERATING_SYSTEM}.sh configuration file instead."
downloadPlatformConfigFile "${ADOPT_PLATFORM_CONFIG_LOCATION}" "${OPERATING_SYSTEM}.sh"

if [ $ret -ne 0 ] || [[ ! $fileContents =~ $contentsErrorRegex ]]
then
echo "[ERROR] Failed to download a platform configuration file from User and Adopt's repositories"
exit 2
fi
fi
fi

echo "[SUCCESS] Config file downloaded successfully to ${PLATFORM_CONFIG_FILEPATH}"
source "${PLATFORM_CONFIG_FILEPATH}"
121 changes: 121 additions & 0 deletions docs/UsingOurScripts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Custom environment setting up guide

Adopt have setup their build scripts so that you can plug in configuration files and scripts you have changed while not having to duplicate and maintain Adopt's entire codebase separately. This may seem complicated at first but it's pretty simple once you get the hang of the process.

## defaults.json

This file contains the default constants and paths used in the build scripts for whichever repository it is located in. As an example, Adopt's `defaults.json` file is located [here](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/defaults.json). If you're unsure of any of the fields, see Adopt's example map below:

```json
{
// Git repository details
"repository" : {
// Git Url of the current repository.
"url" : "https://github.com/AdoptOpenJDK/openjdk-build.git",
// Git branch you wish to use when running the scripts
"branch" : "master"
},
// Jenkins server details
"jenkinsDetails" : {
// The base URL of the server, usually this is where you would end up if you opened your server from a webpage
"rootUrl" : "https://ci.adoptopenjdk.net",
// Jenkins directory where jobs will be generated and run
"rootDirectory" : "build-scripts"
},
// Jenkins job dsl template paths (relative to this repository root)
"templateDirectories" : {
// Downstream job template (e.g. jdk8u-linux-x64-hotspot)
"downstream" : "pipelines/build/common/create_job_from_template.groovy",
// Upstream job template (e.g. openjdk8-pipeline)
"upstream" : "pipelines/jobs/pipeline_job_template.groovy",
// Weekly job template (e.g. weekly-openjdk8-pipeline)
"weekly" : "pipelines/jobs/weekly_release_pipeline_job_template.groovy"
},
// Job configuration file paths (relative to this repository root)
"configDirectories" : {
// Build configs directory containing node details, os, arch, testlists, etc
"build" : "pipelines/jobs/configurations",
// Nightly configs directory containing execution frequency, weekly tags, platforms to build.
"nightly" : "pipelines/jobs/configurations",
// Bash platform script directory containing jdk downloading and toolchain setups.
"platform" : "build-farm/platform-specific-configurations"
},
// Job script paths (relative to this repository root)
"scriptDirectories" : {
// Upstream scripts directory containing the 1st files that are executed by the openjdkx-pipeline jobs.
"upstream" : "pipelines/build",
// Upstream script file containing the 1st script that is executed by the weekly-openjdk8-pipeline jobs.
"weekly" : "pipelines/build/common/weekly_release_pipeline.groovy",
// Downstream script file containing the 1st script that is executed by the jdkx-platform-arch-variant jobs.
"downstream" : "pipelines/build/common/kick_off_build.groovy",
// Base script file containing the 2nd script that is executed by the pipeline_jobs_generator_jdkxx jobs
"regeneration" : "pipelines/build/common/config_regeneration.groovy",
// Base PR tester file script file containing the 2nd script that is executed by the pipeline_jobs_generator_jdkxx jobs
"tester" : "pipelines/build/prTester/pr_test_pipeline.groovy"
},
// Job base file (the main file which is called after the 1st setup script file) paths (relative to this repository root)
"baseFileDirectories": {
// Upstream pipeline file script containing the 2nd script that is executed by the openjdkx-pipeline jobs
"upstream" : "pipelines/build/common/build_base_file.groovy",
// Upstream pipeline file script containing the 2nd script that is executed by the jdkx-platform-arch-variant jobs
"downstream" : "pipelines/build/common/openjdk_build_pipeline.groovy"
},
// Script to import the adopt groovy class library (relative to this repository root)
"importLibraryScript" : "pipelines/build/common/import_lib.groovy"
}
```

### How do I know which parameter the jenkins job will use?

The scripts have been designed with a set hierarchy in mind when choosing which parameter to use:

```md
1. JENKINS PARAMETERS (highest priority, args entered here will be what the build scripts use over everything else)
2. USER JSON (medium priority, args entered here will be used when a jenkins parameter isn't entered)
3. ADOPT JSON (final priority, when jenkins parameters AND a user json arg can't be validated, the script will checkout to this repository and use Adopt's defaults json (linked above))
```

The `ADOPT JSON` level is only used for files and directories. Other parameters (`JOB_ROOT`, `JENKINS_BUILD_ROOT`, etc) only use the first two levels.

As an example, take a look at the [build-pipeline-generator](https://ci.adoptopenjdk.net/job/build-scripts/job/utils/job/build-pipeline-generator/) `SCRIPT_FOLDER_PATH` parameter:

![Image of the SCRIPT_FOLDER_PATH parameter in jenkins](images/scriptFolderParam.png)
The script will use whatever has been entered into the parameter field unless it has been left empty, in which case it will use whatever is in the user's `defaults.json['scriptDirectories']['upstream']` attribute.

It will then evaluate the existence of that directory in the user's repository and, if it fails to find one, will checkout to AdoptOpenJDK/openjdk-build and use Adopt's `defaults.json` (the console log will warn the user of this occuring):

```
00:13:31 [WARNING] pipelines/build/common/weekly_release_pipeline.groovy does not exist in your chosen repository. Updating it to use Adopt's instead
```

NOTE: For the defaults that are paths to directories, the scripts will search for files of the same name as Adopt's. Custom named files are not currently supported (so for `defaults.json['configDirectories']['platform']`, all of the filenames in the specified folder need to be the same as [Adopt's](https://github.com/AdoptOpenJDK/openjdk-build/tree/master/build-farm/platform-specific-configurations) or the script will fail to pick up the user's config's and will use Adopt's instead).

### This is great, but how do I add new defaults?

Create a openjdk-build PR that adds the new defaults in for what they would be for Adopt. Don't forget to update Adopt's [RepoHandlerTest.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/src/test/groovy/RepoHandlerTest.groovy) and [fakeDefaults.json](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/src/test/groovy/fakeDefaults.json), as well as any jenkins jobs if needs be (if you don't have configuration access, ask in Slack#build for assistance). Then update any scripts that will need to handle the new default, you will likely need to do a bit of searching through the objects mentioned in Adopt's `defaults.json` to find where Adopt's scripts will need changing.

Once it has been approved and merged, update your scripts and/or jenkins jobs to handle the new default and you're done!

## Starting from scratch

1. Create a (preferably) public repository with whatever scripts/configs you have altered. You don't need to place them in the same place as where Adopt's ones are, but they should have the same name. Currently, the list of supported files (replacing `x` with the JDK version number you want to alter, `(u)` is optional) you can modify are:

- [pipelines/build/regeneration/build_pipeline_generator.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/regeneration/build_pipeline_generator.groovy) - Main upstream generator files. This is what the [build-pipeline-generator jenkins job](https://ci.adoptopenjdk.net/job/build-scripts/job/utils/job/build-pipeline-generator/) executes on build, generating the [upstream jobs](https://ci.adoptopenjdk.net/job/build-scripts/).
- [pipelines/jobs/pipeline_job_template.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/jobs/pipeline_job_template.groovy) - Upstream jobs dsl. This is the dsl job framework of the [openjdkxx-pipeline downstream jobs](https://ci.adoptopenjdk.net/job/build-scripts).
- [pipelines/jobs/weekly_release_pipeline_job_template.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/jobs/weekly_release_pipeline_job_template.groovy) - Upstream jobs dsl. This is the dsl job framework of the [weekly-openjdkxx-pipeline downstream jobs](https://ci.adoptopenjdk.net/job/build-scripts).
- [pipelines/build/openjdkx_pipeline.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/openjdk8_pipeline.groovy) - Main upstream script files. These are what the [openjdkx-pipeline jenkins jobs](https://ci.adoptopenjdk.net/job/build-scripts/job/openjdk8-pipeline/) execute on build.
- [pipelines/build/common/import_lib.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/common/import_lib.groovy) - Class library import script. This imports [Adopt's classes](https://github.com/AdoptOpenJDK/openjdk-build/tree/master/pipelines/library/src) used in the groovy scripts.
- [pipelines/build/common/build_base_file.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/common/build_base_file.groovy) - Base upstream script file that's called from `pipelines/build/openjdkx_pipeline.groovy`, setting up the [downstream build JSON](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/library/src/common/IndividualBuildConfig.groovy) for each downstream job and executing them.
- [pipelines/jobs/configurations/jdkx(u).groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/jobs/configurations/jdk8u.groovy) - Upstream nightly config files. These define the job schedules, what platforms are instantiated on a nightly build and what tags are used on the weekend releases.
- [pipelines/jobs/configurations/jdkx(u)_pipeline_config.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/jobs/configurations/jdk8u_pipeline_config.groovy) - Downstream build config files, docs for this are [in progress](https://github.com/AdoptOpenJDK/openjdk-build/issues/2129).
- [pipelines/build/common/kick_off_build.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/common/kick_off_build.groovy) - Main downstream scripts file. These are what the [jdkx(u)-os-arch-variant jenkins jobs](https://ci.adoptopenjdk.net/job/build-scripts/job/jobs/job/jdk8u/) execute on build.
- [pipelines/build/common/openjdk_build_pipeline.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/common/openjdk_build_pipeline.groovy) - Base downstream script file. This contains most of the functionality for Adopt's downstream jobs (tests, installers, bash scripts, etc).
- [pipelines/build/regeneration/jdkx_regeneration_pipeline.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/regeneration/jdk8_regeneration_pipeline.groovy) - Main downstream generator files. These are what the [pipeline_jobs_generator_jdk8u jenkins jobs](https://ci.adoptopenjdk.net/job/build-scripts/job/utils/job/pipeline_jobs_generator_jdk8u/) execute on build, generating the [downstream jobs](https://ci.adoptopenjdk.net/job/build-scripts/job/jobs/) via `pipelines/build/common/config_regeneration.groovy` (see below).
- [pipelines/build/common/config_regeneration.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/common/config_regeneration.groovy) - Base downstream script file. These are what the [pipeline_jobs_generator_jdk8u jenkins jobs](https://ci.adoptopenjdk.net/job/build-scripts/job/utils/job/pipeline_jobs_generator_jdk8u/) execute after `jdkx_regeneration_pipeline.groovy`, calling the dsl template `pipelines/build/common/create_job_from_template.groovy`.
- [pipelines/build/common/create_job_from_template.groovy](https://github.com/AdoptOpenJDK/openjdk-build/blob/master/pipelines/build/common/create_job_from_template.groovy) - Downstream jobs dsl. This is the dsl job framework of the [downstream jobs]((https://ci.adoptopenjdk.net/job/build-scripts/job/jobs/)).
2. Create a User JSON file containing your default constants that the build scripts will use (see [#the defaults.json](#defaults.json))
3. Copy the [build-pipeline-generator](https://ci.adoptopenjdk.net/job/build-scripts/job/utils/job/build-pipeline-generator/) and [pipeline_jobs_generator_jdk8u](https://ci.adoptopenjdk.net/job/build-scripts/job/utils/job/pipeline_jobs_generator_jdk8u/) jobs to your Jenkins instance (replace `jdk8u` with whichever version you intend to build, there should be one job for each jdk version).
4. Execute the copied `build-pipeline-generator`. Make sure you have filled in the parameters that are not covered by your `defaults.json` (e.g. `DEFAULTS_URL`, `CHECKOUT_CREDENTIALS`). You should now see that the nightly and weekly pipeline jobs have been successfully created in whatever folder was entered into `JOB_ROOT`
5. Execute the copied `pipeline_jobs_generator_jdkxx` jobs. Again, make sure you have filled in the parameters that are not covered by your `defaults.json`. You should now see that the `jobs/jdkxx-platform-arch-variant` jobs have been successfully created in whatever folder was entered into `JOB_ROOT`

Congratulations! You should now be able to run Adopt's scripts inside your own Jenkins instance.
Binary file added docs/images/scriptFolderParam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading