Skip to content

Commit

Permalink
Updating load_cartridge to support bitbucket scm changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmanshu.singh committed Feb 27, 2017
1 parent 2265052 commit 333de5f
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions projects/jobs/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,29 @@ return cartridge_urls;
mkdir ${WORKSPACE}/tmp
# Output SCM provider ID to a properties file
echo SCM_PROVIDER_ID=$(echo ${SCM_PROVIDER} | cut -d "(" -f2 | cut -d ")" -f1) > scm_provider_id.properties
echo SCM_PROVIDER_ID=$(echo ${SCM_PROVIDER} | cut -d "(" -f2 | cut -d ")" -f1) > scm.properties
# Check if SCM namespace is specified
if [ -z ${SCM_NAMESPACE} ] ; then
echo "SCM_NAMESPACE not specified, setting to PROJECT_NAME..."
SCM_NAMESPACE="${PROJECT_NAME}"
else
echo "SCM_NAMESPACE specified, injecting into properties file..."
fi
echo SCM_NAMESPACE=$(echo ${SCM_NAMESPACE} | cut -d "(" -f2 | cut -d ")" -f1) >> scm.properties
''')
environmentVariables {
propertiesFile('scm_provider_id.properties')
propertiesFile('scm.properties')
}
systemGroovyCommand('''
import com.cloudbees.plugins.credentials.*;
import com.cloudbees.plugins.credentials.common.*;
import pluggable.scm.PropertiesSCMProviderDataStore
import pluggable.scm.SCMProviderDataStore
import pluggable.scm.PropertiesSCMProviderDataStore;
import pluggable.scm.SCMProviderDataStore;
import pluggable.configuration.EnvVarProperty;
import pluggable.scm.helpers.HelperUtils
import java.util.Properties
import hudson.FilePath
import pluggable.scm.helpers.PropertyUtils;
import java.util.Properties;
import hudson.FilePath;
String scmProviderId = build.getEnvironment(listener).get('SCM_PROVIDER_ID')
EnvVarProperty envVarProperty = EnvVarProperty.getInstance();
Expand All @@ -163,7 +172,8 @@ if(credentialId != null){
channel = build.workspace.channel;
fp = new FilePath(channel, build.workspace.toString() + "@tmp/secretFiles/" + build.getEnvVars()["SCM_KEY"])
fp.write("SCM_USERNAME="+credentialInfo[0]+"\\nSCM_PASSWORD="+credentialInfo[1], null);
fp.write("SCM_USERNAME="+credentialInfo[0]+"\\nSCM_PASSWORD="+credentialInfo[1], null);
}
'''){
classpath('${PLUGGABLE_SCM_PROVIDER_PATH}')
Expand Down Expand Up @@ -258,13 +268,13 @@ xmlFiles.each {
configXml.getBytes());
String jobName = configFile.getName()
.substring(0,
.substring(0,
configFile
.getName()
.lastIndexOf('.'));
.lastIndexOf('.'));
jenkinsInstace.getItem(projectName,jenkinsInstace)
.createProjectFromXML(jobName, xmlStream);
.createProjectFromXML(jobName, xmlStream);
println '[INFO] - Imported XML job config: ' + it.toURI();
}
Expand Down Expand Up @@ -318,7 +328,8 @@ if (scmNamespace != null && !scmNamespace.isEmpty()){
}
}
scmProvider.createScmRepos(workspace, repoNamespace, codeReviewEnabled, overwriteRepos)''')
scmProvider.createScmRepos(workspace, repoNamespace, codeReviewEnabled, overwriteRepos)
''')
}
}
parameters("")
Expand Down Expand Up @@ -374,6 +385,10 @@ def cartridgeFolder = folder(cartridgeFolderName) {
}
}
}
environmentVariables {
env('PLUGGABLE_SCM_PROVIDER_PATH','${JENKINS_HOME}/userContent/job_dsl_additional_classpath/')
env('PLUGGABLE_SCM_PROVIDER_PROPERTIES_PATH','${JENKINS_HOME}/userContent/datastore/pluggable/scm')
}
dsl {
external("cartridge/**/jenkins/jobs/dsl/*.groovy")
additionalClasspath("job_dsl_additional_classpath")
Expand Down

0 comments on commit 333de5f

Please sign in to comment.