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

Updating platform jobs for pluggable scm #30

Merged
merged 10 commits into from
Mar 9, 2017

Conversation

dsingh07
Copy link
Contributor

@dsingh07 dsingh07 commented Jan 24, 2017

This pull request will update miscellaneous platform jobs to support Pluggable SCM:

  • A new platform job to deploy the pluggable scm library in your Job DSL additional classpath
  • Updates to Generate_Project to allow you to add a new parameter to Load_Cartridge, letting you set a custom namespace for your repos to be loaded under
  • Updates to Load_Cartridge with a new parameter for SCM_PROVIDER and making it completely agnostic of your chosen SCM provider i.e. no references to Gerrit
  • Supports running load cartridge and masters and unix/linux slaves.

Test Scenarios

  • Backwards compatibility: Load current Java Cartridge
    ** Expect spring petclinic repos to be created in Gerrit
  • Backwards compatibility: Load current DOA Cartridge Collection
  • Test Gerrit SCM Provider with SSH (Java Cartridge)
  • Test Gerrit SCM Provider with SSH and without a cartridge folder name
  • Test Gerrit SCM Provider with HTTPS (Java Cartridge)
  • Test Gerrit SCM Provider with HTTPS and without a cartridge folder name (Java Cartridge)

As the build label is also set to !master the above tests should also confirm we can run the cartridge loader from unix/linux based slaves.

For all tests it is expected the respective repositories captured in urls.txt will be created with the respective SCM provider (Gerrit, BitBucket)

This PR is dependent on:
Accenture/adop-jenkins#29
Accenture/adop-docker-compose#187
Accenture/adop-pluggable-scm#4

// Setup setup_cartridge
setupPluggable.with{
environmentVariables {
keepBuildVariables()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setupPluggable.with{
environmentVariables {
keepBuildVariables()
keepSystemVariables()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dsingh07
Copy link
Contributor Author

Thanks for the review @nickdgriffin

I have fixed that bug now.

Waiting for this PR to get merged in: dsingh07#1 to my branch, and this PR should be in a reviewable state again.

@dsingh07
Copy link
Contributor Author

There have been changes introduced by @BuleGeorge and @RobertNorthard which will be tested by me, after rebasing with all the other changes that have been introduced.

I shall update this PR with exciting developments :)

@dsingh07 dsingh07 added the wip label Feb 22, 2017
@dsingh07 dsingh07 self-assigned this Feb 22, 2017
@dsingh07 dsingh07 force-pushed the feature/pluggable branch 2 times, most recently from 4f48dbd to f3ebf7d Compare February 23, 2017 17:54
@dsingh07 dsingh07 removed their assignment Feb 23, 2017
systemGroovyCommand('''
import jenkins.model.*
import groovy.io.FileType
>>>>>>> Updating platform jobs for pluggable scm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be trimmed out please?

@dsingh07 dsingh07 force-pushed the feature/pluggable branch 4 times, most recently from 00741ee to 333de5f Compare February 27, 2017 17:54
@dsingh07 dsingh07 removed the wip label Feb 27, 2017
# Check if SCM namespace is specified
if [ -z ${SCM_NAMESPACE} ] ; then
echo "SCM_NAMESPACE not specified, setting to PROJECT_NAME..."
SCM_NAMESPACE="${PROJECT_NAME}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SCM_NAMESPACE="${PROJECT_NAME}/${CARTRIDGE_FOLDER}" if cartridge folder has been specified. If not I suspect it will just be empty and default to using the project name.


# Find the cartridge
export CART_HOME=$(dirname $(find -name metadata.cartridge | head -1))

echo "CART_HOME=${CART_HOME}" > ${WORKSPACE}/carthome.properties

# Check if the user has enabled Gerrit Code reviewing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please can we remove all Gerrit references.


def workspace = envVarProperty.getProperty('WORKSPACE')
def projectFolderName = envVarProperty.getProperty('PROJECT_NAME')
def cartridgeFolder = envVarProperty.getProperty('CARTRIDGE_FOLDER')
Copy link
Contributor

@RobertNorthard RobertNorthard Feb 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If CARTRIDGE_FOLDER is not provided we will get a missing property exception. I propose we do something similar to the SCM_NAMESPACE below and default it to '' if it's not provided.

@dsingh07
Copy link
Contributor Author

Thanks for the quick review @RobertNorthard

Have made those changes that you've requested.

@dsingh07 dsingh07 force-pushed the feature/pluggable branch 2 times, most recently from 885e3a0 to 86f3e22 Compare February 28, 2017 15:48
@RobertNorthard
Copy link
Contributor

RobertNorthard commented Feb 28, 2017

Thanks @dsingh07.

@nickdgriffin @anton-kasperovich this requires one final look over (fresh pair of eyes) before we merge.

@dsingh07
Copy link
Contributor Author

Commits have been squashed and is ready for a final round of testing from @nickdgriffin and @anton-kasperovich :)

@@ -2,10 +2,20 @@
def gerritBaseUrl = "ssh://jenkins@gerrit:29418"
def cartridgeBaseUrl = gerritBaseUrl + "/cartridges"
def platformToolsGitUrl = gerritBaseUrl + "/platform-management"
def scmPropertiesPath = "${PLUGGABLE_SCM_PROVIDER_PROPERTIES_PATH}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable looks like it's not used. Please can we remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks @RobertNorthard

@RobertNorthard
Copy link
Contributor

RobertNorthard commented Mar 8, 2017

Thanks @dsingh07 added a few comments in relation to error handling. After this PR is merged, we should also merge Accenture/adop-cartridge-skeleton#3 to demonstrate how to use the pluggable library.


credentialInfo = [CredentialsMatchers.firstOrNull(available_credentials, username_matcher).username,
CredentialsMatchers.firstOrNull(available_credentials, username_matcher).password];

Copy link
Contributor

@RobertNorthard RobertNorthard Mar 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw an unchecked exception (null pointer) if the credentials are not found.

java.lang.NullPointerException: Cannot get property 'username' on null object".

Please can we wrap the username/password extraction so if it throws a NPE a helpful warning message is displayed to the user and default the username/password to an empty string.

The job should not fail if credentials are not found beacuse:

  • the credentials are only required by the SCM create repo section of the cartridge loader
  • not all cartridges will utilise urls.txt as they are just using the SCM provider to generate the appropriate SCM get/triggers.

…arning message to indicate credentials have not been provided.

Signed-off-by: Northard, Robert A <[email protected]>
@RobertNorthard
Copy link
Contributor

RobertNorthard commented Mar 9, 2017

LGTM. Thanks everyone for the hard work.

@dsingh07 @nickdgriffin @anton-kasperovich @BuleGeorge @SachinKSingh28 @marisbahtins @IrmantasM

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

Successfully merging this pull request may close these issues.

4 participants