[jbosstools-issues] [JBoss JIRA] (JBIDE-25804) Integration tests are not able to download eclipse

Lukáš Valach (JIRA) issues at jboss.org
Thu Mar 8 03:31:00 EST 2018


    [ https://issues.jboss.org/browse/JBIDE-25804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13543216#comment-13543216 ] 

Lukáš Valach commented on JBIDE-25804:
--------------------------------------

I replaced the bash script which was responsible for processing of jbosstools-jenkins.properties \[1\] by groovy script \[2\]. Groovy script GetEclipseLink.groovy is stored in jenkins (Jenkins->Scriptler) because it needs a permission to set environment variable. The advantage is that now we can maintain single script instead of maintaining a copy of bash code in each job. Groovy script also don't have to be followed be "Inject environment variable" build step.

\[1\]
{code}
# If $ECLIPSE_URL is set, it will be used, otherwise URL from GitHub/jbosstools-jenkins.properties will be used.

# fetch eclipse tarball from jbosstools-jenkins.properties
curl -s -S -k https://raw.githubusercontent.com/jbosstools/jbosstools-build-ci/master/util/jbosstools-jenkins.properties > jbosstools-jenkins.properties
downloadPhpURL=`grep -Po '(?<=downloadPhpURL=).*' jbosstools-jenkins.properties`
eclipseJeeURL=`grep -Po '(?<=eclipseJeeURL=).*' jbosstools-jenkins.properties`

if [ -z "$ECLIPSE_URL" ]
then
	echo "\$ECLIPSE_URL is empty, a configuration from github/jbosstools-jenkins.properties will be used."
	if [[ $a == "/*" ]]; then
		#There is relative path in eclipseJeeURL, have to be connected with downloadPhpURL
		echo "FINAL_ECLIPSE_URL=${downloadPhpURL}${eclipseJeeURL}" >> jbosstools-jenkins.properties
	else
        echo "FINAL_ECLIPSE_URL=${eclipseJeeURL}" >> jbosstools-jenkins.properties
	fi
	cat jbosstools-jenkins.properties   
else 
	echo "\$ECLIPSE_URL is set."
    echo "FINAL_ECLIPSE_URL=${ECLIPSE_URL}" >> jbosstools-jenkins.properties
    cat jbosstools-jenkins.properties
fi
{code}

\[2\]
{code}
/**
 * Finds and set link to eclipse.tar.gz into FINAL_ECLIPSE_URL parameter. If property ECLIPSE_URL is set (and isn't empty), its value will be used, otherwise URL will be taken from https://raw.githubusercontent.com/jbosstools/jbosstools-build-ci/master/util/jbosstools-jenkins.properties
 *
 * This script uses some features of Hudson API which may requires additional permissions. See  JBIDE-25515.
 * 
* @author Lukas Valach (lvalach at redhat.com)
 */
import hudson.model.ParametersAction;
import hudson.model.StringParameterValue;

final String eclipseUrlEnvVariable = 'ECLIPSE_URL'
final String finalEclipseUrlEnvVariable = 'FINAL_ECLIPSE_URL'
final String jbosstoolsJenkinsProperties = 'https://raw.githubusercontent.com/jbosstools/jbosstools-build-ci/master/util/jbosstools-jenkins.properties'


def config = new HashMap();
def bindings = getBinding();
config.putAll(bindings.getVariables());
def out = config['out'];

// load ECLIPSE_URL property
final currentJobExecutable = Thread.currentThread().executable;
final eclipseUrl = currentJobExecutable.properties.get("envVars")[eclipseUrlEnvVariable];

// if ECLIPSE_URL is set and isn't empty then use its original value
if (eclipseUrl != null && !eclipseUrl.empty) {
	printDebugMessage("Property " + eclipseUrlEnvVariable + " is set, so its value will be copied into " + finalEclipseUrlEnvVariable + " property.");
	setJenkinsParameter(finalEclipseUrlEnvVariable,eclipseUrl);
	return;
} 

printDebugMessage("Configuration will be loaded from: " + jbosstoolsJenkinsProperties);

// load propeties from configuration file
Properties jbtProps =  propertyFileFromUrl(jbosstoolsJenkinsProperties);
String downloadPhpURL = jbtProps.getProperty("downloadPhpURL");
String eclipseJeeURL = jbtProps.getProperty("eclipseJeeURL");
printDebugMessage("Property downloadPhpURL=" + downloadPhpURL);
printDebugMessage("Property eclipseJeeURL=" + eclipseJeeURL);

String finalDownloadUrl;
if (eclipseJeeURL.startsWith("/")) {
  	printDebugMessage("There is relative path in eclipseJeeURL property, so it have to be connected with downloadPhpURL.");
	finalDownloadUrl = downloadPhpURL + eclipseJeeURL;
} else {
	finalDownloadUrl = eclipseJeeURL;
}


setJenkinsParameter(finalEclipseUrlEnvVariable,finalDownloadUrl);

// read properties from properties file at given url
private static Properties propertyFileFromUrl(String url){
	InputStream is = new URL(url).openConnection().getInputStream();
	def props = new Properties();
	props.load(is);
	is.close();
	return props;
}

// set value of jenkins parameter
private void setJenkinsParameter (String paramName , String paramValue){
	def parameterAction = new ParametersAction(new StringParameterValue(paramName, paramValue));
	printDebugMessage("Sets Jenkins paramter: [" + paramName + ":" + paramValue + "]");
	Thread.currentThread().executable.addAction(parameterAction);
}

// print debug message
def printDebugMessage (message){
	out.println "[GetEclipseLink.groovy] " + message;
}
{code}

> Integration tests are not able to download eclipse
> --------------------------------------------------
>
>                 Key: JBIDE-25804
>                 URL: https://issues.jboss.org/browse/JBIDE-25804
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: integration-tests
>    Affects Versions: 4.5.3.AM3
>            Reporter: Lukáš Valach
>            Assignee: Lukáš Valach
>             Fix For: 4.5.3.AM3
>
>
> There is a configuration file \[1\] which contains URL to latest Eclipse. Since 4.5.3.AM2 there is absolute path in eclipseJeeURL, but my test are able to work only with relative path. I have to adapt them.
> \[1\] https://raw.githubusercontent.com/jbosstools/jbosstools-build-ci/master/util/jbosstools-jenkins.properties
> Next problem is that script getAndInstallEclipse.groovy is not albe to download eclipse from \[2\] (maybe because of HTTPS?)
> \[2\] https://ci.eclipse.org/packaging/job/oxygen.epp-tycho-build/455/artifact/org.eclipse.epp.packages/archive/20180222-1826_eclipse-jee-oxygen-3-rc2-linux.gtk.x86_64.tar.gz
> Affected jobs:
> https://dev-platform-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/Devstudio/view/devstudio_installer_tests/job/Devstudio_Installation/job/BYOE_Installation/job/Install_JBDS_from_installer_jar/
> https://dev-platform-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/Devstudio/view/devstudio_installer_tests/job/Devstudio_Installation/job/BYOE_Installation/job/Install_JBDS_online_update_site/
> https://dev-platform-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/Devstudio/view/devstudio_installer_tests/job/Devstudio_Installation/job/BYOE_Installation/job/Install_JBDS_update_core_zip/
> https://dev-platform-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/Devstudio/view/devstudio_installer_tests/job/Devstudio_Installation/job/BYOE_Installation/job/Install_JBoss_Tools_online_update_site/
> https://dev-platform-jenkins.rhev-ci-vms.eng.rdu2.redhat.com/view/Devstudio/view/devstudio_installer_tests/job/Devstudio_Installation/job/Post_install_tests/job/Install_sw_from_central_JBossTools/



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)



More information about the jbosstools-issues mailing list