Skip to content
Snippets Groups Projects
Commit ec3a0d00 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Merge branch 'malowe/master/246' into 'master'

Iss #246 - Update Jenkinsfile for testing scripts and resolving issues

Closes #246

See merge request eclipsefdn/it/webdev/eclipsefdn-vc-tools!248
parents 4d60dc9a 3a7197e2
No related branches found
No related tags found
1 merge request!248Iss #246 - Update Jenkinsfile for testing scripts and resolving issues
Pipeline #15695 passed
......@@ -3,33 +3,72 @@
pipeline {
agent {
kubernetes {
label 'kubedeploy-agent'
label 'buildenv-agent'
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: kubectl
image: eclipsefdn/kubectl:okd-c1-1.24.2
command:
- cat
tty: true
resources:
limits:
cpu: 1
memory: 1Gi
volumeMounts:
- mountPath: "/home/default/.kube"
name: "dot-kube"
readOnly: false
- name: jnlp
resources:
limits:
cpu: 1
memory: 1Gi
volumes:
- name: "dot-kube"
emptyDir: {}
apiVersion: v1
kind: Pod
spec:
containers:
- name: buildcontainer
image: eclipsefdn/stack-build-agent:latest
imagePullPolicy: Always
command:
- cat
tty: true
resources:
requests:
cpu: "1"
memory: "4Gi"
limits:
cpu: "2"
memory: "4Gi"
env:
- name: "HOME"
value: "/home/jenkins"
- name: "MAVEN_OPTS"
value: "-Duser.home=/home/jenkins"
volumeMounts:
- name: m2-repo
mountPath: /home/jenkins/.m2/repository
- name: m2-secret-dir
mountPath: /home/jenkins/.m2/settings.xml
subPath: settings.xml
readOnly: true
- mountPath: "/home/jenkins/.m2/settings-security.xml"
name: "m2-secret-dir"
readOnly: true
subPath: "settings-security.xml"
- mountPath: "/home/jenkins/.mavenrc"
name: "m2-dir"
readOnly: true
subPath: ".mavenrc"
- mountPath: "/home/jenkins/.m2/wrapper"
name: "m2-wrapper"
readOnly: false
- mountPath: "/home/jenkins/.cache"
name: "yarn-cache"
readOnly: false
- name: jnlp
resources:
requests:
memory: "1024Mi"
cpu: "500m"
limits:
memory: "1024Mi"
cpu: "1000m"
volumes:
- name: "m2-dir"
configMap:
name: "m2-dir"
- name: m2-secret-dir
secret:
secretName: m2-secret-dir
- name: m2-repo
emptyDir: {}
- name: m2-wrapper
emptyDir: {}
- name: yarn-cache
emptyDir: {}
'''
}
}
......@@ -62,6 +101,18 @@ pipeline {
}
stages {
stage('Test sync scripts') {
steps {
container('buildcontainer') {
readTrusted 'package.json'
sh '''
npm ci --no-cache && npm run test
'''
}
}
}
stage('Build docker image') {
agent {
label 'docker-build'
......@@ -97,6 +148,38 @@ pipeline {
}
stage('Deploy to cluster') {
agent {
kubernetes {
label 'kubedeploy-agent'
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: kubectl
image: eclipsefdn/kubectl:okd-c1
command:
- cat
tty: true
resources:
limits:
cpu: 1
memory: 1Gi
volumeMounts:
- mountPath: "/home/default/.kube"
name: "dot-kube"
readOnly: false
- name: jnlp
resources:
limits:
cpu: 1
memory: 1Gi
volumes:
- name: "dot-kube"
emptyDir: {}
'''
}
}
when {
branch 'production'
}
......
This diff is collapsed.
......@@ -42,6 +42,7 @@
"yargs": "^13.3.0"
},
"devDependencies": {
"@babel/core": "^7.21.3",
"@babel/eslint-parser": "^7.17.0",
"@types/mocha": "^9.1.1",
"@types/parse-link-header": "^2.0.0",
......@@ -53,7 +54,7 @@
"eslint": "^7.5.0",
"eslint-config-strongloop": "^2.1.0",
"faker": "^5.5.3",
"mocha": "^7.0.1",
"mocha": "^10.2.0",
"sinon": "^10.0.0"
}
}
......@@ -170,7 +170,7 @@ module.exports = class EclipseAPI {
// set back to ensure properly set
data[key] = project;
}
return data.filter(p => p.state.toLowerCase() !== 'archived');
return data.filter(p => p.state !== undefined && p.state.toLowerCase() !== 'archived');
}
async eclipseUser(username) {
......
......@@ -542,7 +542,7 @@ module.exports = class {
.then(result => result)
.catch(err => logError(err, 'teams:listRepos'));
}
/**
* Retrieves repos for a given organization. Returns raw results with no cache.
*/
......
......@@ -72,6 +72,7 @@ const DEFAULT_ORG_PERMISSIONS = {
members_allowed_repository_creation_type: 'none',
};
const DENYLIST_ORGS_ORG_WIDE_PROJECT = ['eclipse'];
const HTTP_NOT_FOUND_STATUS = 404;
const { getLogger } = require('./logger.js');
const logger = getLogger(argv.V ? 'debug' : 'info', 'main');
......@@ -203,7 +204,7 @@ async function runSync(data) {
async function handleOrgWideProject(project) {
// check that this code should be used in this project
const projectOrg = project.github.org;
if (projectOrg === undefined || projectOrg.trim() === ''
if (projectOrg === undefined || projectOrg.trim() === ''
|| DENYLIST_ORGS_ORG_WIDE_PROJECT.includes(projectOrg.trim().toLowerCase())) {
logger.info(`Project ${project.project_id} does not have a valid Github project org set, not using org wide logic`);
return [];
......@@ -214,15 +215,15 @@ async function handleOrgWideProject(project) {
logger.info(`Project ${project.project_id} is outside of target org ${argv.T} and will be skipped.`);
return [];
}
// get the repos from Github for current organization and convert into simplified format
return (await wrap.getReposForOrg(projectOrg.trim().toLowerCase()))
.filter(r => project.github.ignored_repos.indexOf(r.name) === -1).map(r => {
return {
"org": projectOrg,
"repo": r.name,
};
});
.filter(r => project.github.ignored_repos.indexOf(r.name) === -1).map(r => {
return {
org: projectOrg,
repo: r.name,
};
});
}
/**
......@@ -345,7 +346,8 @@ async function processProjectsOrg(org, project) {
updateProjectTeam(org, project, 'contributors'),
updateProjectTeam(org, project, 'committers'),
updateProjectTeam(org, project, 'project_leads')]);
logger.debug(`Finished creating teams for ${project} in org '${org}' with ${done.filter(status => status.status !== 'fulfilled').length} errors.`);
logger.debug(`Finished creating teams for ${project} in org '${org}' with `
+ `${done.filter(status => status.status !== 'fulfilled').length} errors.`);
} else {
logger.debug('Dry run set, not adding teams for org: ' + org);
}
......@@ -434,18 +436,18 @@ async function updateTeam(org, teamName, designatedMembers, project) {
members.forEach(async member => {
// bot check before deletion, skipping if user is bot
if (!isUserBot(member.login, project)) {
if (argv.D !== true) {
logger.info(`Removing '${member.login}' from team '${teamName}'`);
await wrap.removeUserFromTeam(org, teamName, member.login);
} else {
logger.debug(`Would have deleted '${member.login}', but in semi-dry run mode`);
}
if (argv.D !== true) {
logger.info(`Removing '${member.login}' from team '${teamName}'`);
await wrap.removeUserFromTeam(org, teamName, member.login);
} else {
logger.debug(`Would have deleted '${member.login}', but in semi-dry run mode`);
}
} else {
logger.verbose(`User '${member.login}' from team '${teamName}' identified as a bot, skipping`);
}
});
} else {
logger.info(`An error encountered while processing team members, users will not be removed from this team on this run`);
logger.info('An error encountered while processing team members, users will not be removed from this team on this run');
}
}
}
......@@ -462,7 +464,7 @@ async function updateTeam(org, teamName, designatedMembers, project) {
* returns true if the user is missing, false if any other kind of error
*/
function checkIfUserIsMissing(response) {
return response != null && response.status === 404 && response.data instanceof Array
return response != null && response.status === HTTP_NOT_FOUND_STATUS && response.data instanceof Array
&& response.data[0].localeCompare('User not found.', undefined, { sensitivity: 'base' }) === 0;
}
......
......@@ -49,7 +49,8 @@ describe('EclipseAPI', function() {
{
"url": "http://www.github.com/second-org/cool-code"
}
]
],
"state": "Active"
}], "github_repos");
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment