I have a jenkins pipeline which builds & deploy an angular application.
Is it possible to introduce a build parameter from Jenkins during build and display it in the angular application?
Edit:
The purpose is to introduce a parameter at the build time in jenkins pipeline which will take input during build time for describing the issue (for example: JIRA number of an issue) for which this build is getting created. It is then needed to display this issue/bugfix number in the angular application so that the user can see this fix number in the application footer and is sure about the fix deployed in the application. I hope to clarify the problem.
I started with available environment variable build number to start with & tried to use following script in Jenkins pipeline script stage('Replace'){ agent any when { environment name: 'showVersionCheckout', value: 'true'} steps {
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'xyz', url: 'https://abcd.git']]])
script {
sh "sed -i -e 's/VERSION/${env.version}/g' src/environments/environment.dev.ts"
}
}
}
In Angular app: export const environment = { production: false, VERSION: '0.0.2' }
So when the Jenkins pipeline builds the angular application, i still see the old value of 0.0.2 instead of what we replaced using sed.
Can anyone help ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…