Version 1.0.4 - Remove pipelines
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Deployment Pipeline / deploy (push) Successful in 26s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Deployment Pipeline / deploy (push) Successful in 26s
				
			This commit is contained in:
		@@ -37,12 +37,11 @@ module.exports.updateFile = function (file) {
 | 
			
		||||
 | 
			
		||||
module.exports.getSettings = function () {
 | 
			
		||||
    const file = this.getFile()
 | 
			
		||||
    return {"jenkins_token": file.JENKINS_TOKEN, "omega_token": file.OMEGA_KEY}
 | 
			
		||||
    return {"omega_token": file.OMEGA_KEY}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.saveSettings = function (settings) {
 | 
			
		||||
    const file = this.getFile()
 | 
			
		||||
    file.JENKINS_TOKEN = settings.jenkins_token
 | 
			
		||||
    file.OMEGA_KEY = settings.omega_token
 | 
			
		||||
    this.updateFile(file)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										138
									
								
								bin/pipelines.js
									
									
									
									
									
								
							
							
						
						
									
										138
									
								
								bin/pipelines.js
									
									
									
									
									
								
							@@ -1,138 +0,0 @@
 | 
			
		||||
const { LogType } = require("loguix")
 | 
			
		||||
const fs = require("fs")
 | 
			
		||||
const path = require("path")
 | 
			
		||||
const { __glob } = require("./global-variables")
 | 
			
		||||
const clog = new LogType("Pïpeline")
 | 
			
		||||
const config = require("./config")
 | 
			
		||||
 | 
			
		||||
const tokenkey = config.getFile().JENKINS_TOKEN
 | 
			
		||||
 | 
			
		||||
module.exports.getAllPipelines = function() {
 | 
			
		||||
 | 
			
		||||
    return new Promise((resolve, reject) => {
 | 
			
		||||
       
 | 
			
		||||
        
 | 
			
		||||
        fetch(`https://jenkins.raphix.fr/api/json`, {
 | 
			
		||||
            method: "GET",
 | 
			
		||||
            headers: {
 | 
			
		||||
                "Accept": "application/json",
 | 
			
		||||
                "Authorization": `Basic ${tokenkey}`
 | 
			
		||||
            },
 | 
			
		||||
            credentials: "include"
 | 
			
		||||
        })
 | 
			
		||||
        .then(res => res.json())
 | 
			
		||||
        .then(async list  => {
 | 
			
		||||
 | 
			
		||||
            const pipelinesJobs = new Array()
 | 
			
		||||
 | 
			
		||||
            for(const job of list.jobs) {
 | 
			
		||||
                    await fetch(`${job.url}/api/json`, {
 | 
			
		||||
                    method: "GET",
 | 
			
		||||
                    headers: {
 | 
			
		||||
                        "Accept": "application/json",
 | 
			
		||||
                        "Authorization": `Basic ${tokenkey}`
 | 
			
		||||
                    },
 | 
			
		||||
                    credentials: "include"
 | 
			
		||||
                    })
 | 
			
		||||
                    .then(res => res.json())
 | 
			
		||||
                    .then(async res => {
 | 
			
		||||
 | 
			
		||||
                       if(res._class == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject") {
 | 
			
		||||
                            await getJobMain(res).then(resJ => {
 | 
			
		||||
                                res.jobs[0] = resJ
 | 
			
		||||
                                pipelinesJobs.push(res)
 | 
			
		||||
                            })
 | 
			
		||||
                       } else {
 | 
			
		||||
                            pipelinesJobs.push(res)
 | 
			
		||||
 | 
			
		||||
                       }
 | 
			
		||||
 | 
			
		||||
                 
 | 
			
		||||
                    })
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            list.jobs = pipelinesJobs
 | 
			
		||||
 | 
			
		||||
            resolve(list)
 | 
			
		||||
 | 
			
		||||
           
 | 
			
		||||
        })
 | 
			
		||||
        .catch(err => {
 | 
			
		||||
            resolve("UNAVAILABLE")
 | 
			
		||||
        })
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports.startPipeline = function(pipeline) {
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
// If it's a freestyle job, build with params
 | 
			
		||||
 | 
			
		||||
    if(pipeline.type == "org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject") {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
            fetch(`${pipeline.url}/job/${pipeline.jobname}/build?delay=0sec`, {
 | 
			
		||||
                method: "POST",
 | 
			
		||||
                headers: {
 | 
			
		||||
                    "Authorization": `Basic ${tokenkey}`
 | 
			
		||||
                },
 | 
			
		||||
                credentials: "include"
 | 
			
		||||
            })
 | 
			
		||||
            .then(res => {
 | 
			
		||||
                resolve("OK")
 | 
			
		||||
            })
 | 
			
		||||
        })
 | 
			
		||||
    } else {
 | 
			
		||||
        return new Promise((resolve, reject) => {
 | 
			
		||||
 | 
			
		||||
            const parameters = pipeline.fields
 | 
			
		||||
 | 
			
		||||
            const formatedParams = new URLSearchParams()
 | 
			
		||||
 | 
			
		||||
            for(const param of parameters) {
 | 
			
		||||
                formatedParams.append(param.name, param.value)
 | 
			
		||||
            }
 | 
			
		||||
         
 | 
			
		||||
          
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            fetch(`${pipeline.url}/buildWithParameters?delay=0sec`, {
 | 
			
		||||
                method: "POST",
 | 
			
		||||
                headers: {
 | 
			
		||||
                    "Authorization": `Basic ${tokenkey}`,
 | 
			
		||||
                    "Content-Type": "application/x-www-form-urlencoded"
 | 
			
		||||
                },
 | 
			
		||||
                credentials: "include",
 | 
			
		||||
                body: formatedParams
 | 
			
		||||
            })
 | 
			
		||||
            .then(res => {
 | 
			
		||||
                resolve("OK")
 | 
			
		||||
            })
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getJobMain(res) {
 | 
			
		||||
 | 
			
		||||
    return new Promise(async (resolve,  reject) => {
 | 
			
		||||
        
 | 
			
		||||
        await fetch(`${res.jobs[0].url}/api/json`, {
 | 
			
		||||
            method: "GET",
 | 
			
		||||
            headers: {
 | 
			
		||||
                'Accept': 'application/json',
 | 
			
		||||
                'Authorization': `Basic ${tokenkey}`
 | 
			
		||||
            },
 | 
			
		||||
            credentials: 'include'
 | 
			
		||||
        }).then(res => res.json())
 | 
			
		||||
        .then(res => {
 | 
			
		||||
            resolve(res)
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
       
 | 
			
		||||
    })
 | 
			
		||||
        
 | 
			
		||||
}
 | 
			
		||||
@@ -8,7 +8,6 @@ const files = require("./files.js")
 | 
			
		||||
const config = require("./config.js")
 | 
			
		||||
const links = require("./links.js")
 | 
			
		||||
const service = require("./services.js")
 | 
			
		||||
const pipeline = require("./pipelines.js")
 | 
			
		||||
const plog = new LogType("Web")
 | 
			
		||||
const cook = require("cookie")
 | 
			
		||||
const http = require("http")
 | 
			
		||||
@@ -166,16 +165,6 @@ module.exports.serverIO = function(server) {
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if(user.checkPermission("PIPELINES")) {
 | 
			
		||||
                GetRequest("PL_GET_ALL", async () => {
 | 
			
		||||
                    GetAnswer("PL_GET_ALL", await pipeline.getAllPipelines())
 | 
			
		||||
                })
 | 
			
		||||
 | 
			
		||||
                PostRequest("PL_START", async (settings) => {
 | 
			
		||||
                    PostAnswer("PL_START", await pipeline.startPipeline(settings))
 | 
			
		||||
                })
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if(user.checkPermission("USERS")) {
 | 
			
		||||
                GetRequest("US_ALL", async () => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user