Commit d22d4090 authored by canterburym's avatar canterburym Committed by Miguel Angel Reina Ortega
Browse files

Merging changes to support SA5 integration of changemark tool

parent 88fe9a4f
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
#!/bin/bash

DOCKER_IMAGE=forge.3gpp.org:5050/tools/3gpp-scripts/forgelib:v1.0.0

echo "\n------ Checking for docker image --------"
docker pull "$DOCKER_IMAGE"

echo "------ Removing previous outputs --------"
rm *.docx

echo "------ Parsing repo URL --------"

HOST_URL=$(echo $1 | cut -d'/' -f 1-3)
PROJECT_NAME=$(echo $1 | cut -d'/' -f 5- | cut -d'.' -f 1)
echo "HOST URL:" $HOST_URL
echo "PROJECT NAME:" $PROJECT_NAME
echo "PROJECT ID:" $2
echo "MERGE IID:" $3

echo "\n------ Generating change marks --------"
docker container run --rm -v$(pwd):/tmp/ "$DOCKER_IMAGE" forgelib-changedocs -vv --outPath=/tmp/ "$HOST_URL" "$2" "$PROJECT_NAME" "$3"

exit 0
+52 −4
Original line number Diff line number Diff line
@@ -3,13 +3,14 @@ pipeline {
    options {
        disableConcurrentBuilds()
        gitLabConnection('Gitlab for 3GPP')
        gitlabBuilds(builds: ["Resolve", "YANG Strict", "YANG 3GPP Checks", "Validate OpenAPI"])
        gitlabBuilds(builds: ["Resolve", "YANG Strict", "YANG 3GPP Checks", "Validate OpenAPI", "Generate CR text"])
    }
     
	agent any

	environment {
		def resolveSucceded = "false"
        def generationSucceded = "false"
	}
	
	stages {
@@ -71,6 +72,29 @@ pipeline {
                sh 'bash ./scripts/validate-all.sh ./data-models/OpenAPI'
                updateGitlabCommitStatus name: 'Validate OpenAPI', state: 'success'
            }
        }
        stage('Generate CR text') {
            when {
                expression {
                    env.gitlabMergeRequestIid != null
                }
            }
            steps {
                updateGitlabCommitStatus name: 'Generate CR text', state: 'pending'
                sh 'echo Generate CR text stage'

                echo "Source Repo URL ${env.gitlabSourceRepoHttpUrl}"
                echo "Target repo project ID ${gitlabMergeRequestTargetProjectId}"
                echo "Target branch: ${env.gitlabTargetBranch}"
                echo "Source branch: ${env.gitlabSourceBranch}"
                echo "MergeIID: ${env.gitlabMergeRequestIid}"

                sh "bash ./generate_changemarks.sh ${env.gitlabSourceRepoHttpUrl} ${gitlabMergeRequestTargetProjectId} ${env.gitlabMergeRequestIid}"
                updateGitlabCommitStatus name: 'Generate CR text', state: 'success'
                script {
					generationSucceded = "true"
			    }
            }
        }        
		stage('Deploy to FTP') {
    		steps{
@@ -81,7 +105,14 @@ pipeline {
	
    post {
		always {
                script{
                    if (generationSucceded == "false") {
					    archiveArtifacts artifacts: '**/*.log'
                        updateGitlabCommitStatus name: 'Generate CR text', state: 'success'
				    } else {
                        archiveArtifacts artifacts: '**/*.log, *.docx'
                    }
                }
        	}		

        success {
@@ -106,7 +137,24 @@ pipeline {
                body: "Your contribution to 3GPP Forge was applied successfully and, " +
                    "after running the validation process for all the files in the repository, " +
                    "no critical errors were detected.\n" +
                    "Detailed information in the attachments and in 'Console output' at ${env.BUILD_URL}" 
                    "Detailed information in the attachments and in 'Console output' at ${env.BUILD_URL}. "

            script {
                if (generationSucceded == "true") {
				    echo "Sending email to: ${RECIPIENT}"
                    emailext to: "${RECIPIENT}",
                        attachLog: false,
                        attachmentsPattern: '**/*.docx',
                        subject: "[3GPP Forge] Generation succeeded: ${currentBuild.fullDisplayName}, commit ${COMMIT_HASH}",
                        body: "Your contribution to 3GPP Forge was applied successfully and, " +
                        "a Word document has been generated that summarizes all changes in your merge request." +
                        "If you have received a Word attachment which appears to contain no changes, it is likely " + 
                        "your change exceeds " +
                        "Gitlab's diff limits (see https://docs.gitlab.com/ee/user/admin_area/diff_limits.html). In this " + 
                        "case, the change marks will need to be generated by hand."
                    }
                }

            }

		failure {