Python function to tag aws instances based on AMI name

Posted by Scratches on September 6, 2022

sample jenkinsfile to run script from git repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
pipeline {
    parameters {
        string defaultValue: '1234567890', name: 'account-number'
    }
    environment {
        WORKPLACE_TOKEN = credentials('example-auth-token')
    }
    agent any
    stages {
        stage('Hello') {
            steps {
                sh 'echo Running Step 1'
            }
        }
    }
    post {
        always {
            git(url: 'https://github.org/davidhullster/jenkins-git-integration.git', branch: 'jenkins-git-integration', credentialsId: 'git-credentials')
            script {
                    sh '''
                    chmod +x scripts/example_python_script.py
                    python3 -m venv venv; source venv/bin/activate; pip install requests; python3 scripts/example_python_script.py "${account-number}"
                    '''
                }
        }
    }
}