Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To upload a parameter file to GitHub using a Jenkins job, you can follow these steps:

  1. In your Jenkins job, add a step to the pipeline to copy the parameter file to a desired location in the workspace directory.

  2. Add another step to create a new branch in the GitHub repository where you want to upload the parameter file.

  3. Configure the Git credentials in the Jenkins job and use the git command to add and commit the parameter file to the new branch.

  4. Finally, use the git push command to push the changes to the GitHub repository.

Here is an example pipeline:

pipeline {
  agent any

  stages {
    stage("Copy parameter file") {
      steps {
        sh "cp /path/to/parameter/file ${workspace}/parameter.txt"
      }
    }
    stage("Create new branch") {
      steps {
        git branch: 'new-branch', credentialsId: 'git-credentials', url: 'https://github.com/username/repo.git'
      }
    }
    stage("Commit and push") {
      steps {
        sh "cd ${workspace} && git add . && git commit -m 'Add parameter file' && git push origin new-branch"
      }
    }
  }
}

Note: You will need to replace the /path/to/parameter/file, username/repo, and git-credentials values with your own.